示例#1
0
        public static CheckoutPolicy RetrievePolicy(string barcode, IClassificationService classificationService)
        {
            var classification = Holding.ClassificationFromBarcode(barcode);
            var material       = classificationService.Retrieve(classification);

            return(material.CheckoutPolicy);
        }
示例#2
0
            private CheckoutPolicy RetrievePolicy(string barcode)
            {
                var classification = Holding.ClassificationFromBarcode(barcode);
                var material       = classificationService.Object.Retrieve(classification);

                return(material.CheckoutPolicy);
            }
示例#3
0
        void ScanNewMaterial(string barcode)
        {
            var classification = Holding.ClassificationFromBarcode(barcode);
            var isbn           = "x";

            classificationService.Setup(service => service.Classification(isbn)).Returns(classification);
            scanner.AddNewMaterial(isbn);
        }
示例#4
0
 public void ClassificationFromBarcode()
 {
     try
     {
         Assert.Equal("QA234", Holding.ClassificationFromBarcode(ExpectedBarcode));
     }
     catch (FormatException)
     {
         Assert.True(false, "should not thro fmt except");
     }
 }
示例#5
0
 public void ClassificationFromBarcode()
 {
     try
     {
         Assert.That(Holding.ClassificationFromBarcode(ExpectedBarcode), Is.EqualTo("QA234"));
     }
     catch (FormatException)
     {
         Assert.Fail("fail");
     }
 }
示例#6
0
            public void SecondPatronCanCheckOutSecondCopyOfSameClassification()
            {
                string barcode1Copy2 = Holding.GenerateBarcode(Holding.ClassificationFromBarcode(SomeBarcode), 2);

                ScanNewMaterial(barcode1Copy2);

                var patronId2 = patronRepo.Create(new Patron());

                scanner.AcceptLibraryCard(patronId2);
                scanner.AcceptBarcode(barcode1Copy2);

                Assert.That(GetByBarcode(barcode1Copy2).HeldByPatronId, Is.EqualTo(patronId2));
            }
        public void SecondPatronCanCheckOutSecondCopyOfSameClassification()
        {
            var barcode1Copy2 = Holding.GenerateBarcode(Holding.ClassificationFromBarcode(SomeBarcode), 2);

            scanner.ScanNewMaterial(barcode1Copy2, classificationServiceMock);

            var patronId2 = patronsService.Create(new Patron {
                Name = ""
            });

            scanner.AcceptLibraryCard(patronId2);
            scanner.AcceptBarcode(barcode1Copy2);

            Assert.Equal(patronId2, holdingsService.FindByBarcode(barcode1Copy2).HeldByPatronId);
        }
        public static void ScanNewMaterial(this ScanStation scanner, string barcode,
                                           Mock <IClassificationService> serviceMock)
        {
            var classification = Holding.ClassificationFromBarcode(barcode);
            var isbn           = "x";
            var material       = new Material
            {
                Author         = "Long",
                CheckoutPolicy = CheckoutPolicies.BookCheckoutPolicy,
                Title          = "A Book",
                Year           = "2001",
                Classification = classification
            };

            serviceMock.Setup(service => service.Classification(isbn)).Returns(classification);
            serviceMock.Setup(service => service.Retrieve(classification)).Returns(material);
            scanner.AddNewHolding(isbn);
        }
示例#9
0
        // 1/19/2017: who wrote this?
        //
        // FIXME. Fix this mess. We just have to SHIP IT for nwo!!!
        public void AcceptBarcode(string bc)
        {
            var cl = Holding.ClassificationFromBarcode(bc);
            var cn = Holding.CopyNumberFromBarcode(bc);
            var h  = holdingsService.FindByBarcode(bc);

            if (h.IsCheckedOut)
            {
                if (cur == NoPatron)
                {
                    // ci
                    bc = h.Barcode;
                    var      patronId = h.HeldByPatronId;
                    var      cis      = TimeService.Now;
                    Material m        = null;
                    m = classificationService.Retrieve(h.Classification);
                    var    fine = m.CheckoutPolicy.FineAmount(h.CheckOutTimestamp.Value, cis);
                    Patron p    = patronsService.FindById(patronId);
                    p.Fine(fine);
                    patronsService.Update(p);
                    h.CheckIn(cis, brId);
                    holdingsService.Update(h);
                }
                else
                {
                    if (h.HeldByPatronId != cur) // check out book already cked-out
                    {
                        var bc1 = h.Barcode;
                        var n   = TimeService.Now;
                        var t   = TimeService.Now.AddDays(21);
                        var f   = classificationService.Retrieve(h.Classification).CheckoutPolicy
                                  .FineAmount(h.CheckOutTimestamp.Value, n);
                        var patron = patronsService.FindById(h.HeldByPatronId);
                        patron.Fine(f);
                        patronsService.Update(patron);
                        h.CheckIn(n, brId);
                        holdingsService.Update(h);
                        // co
                        h.CheckOut(n, cur, CheckoutPolicies.BookCheckoutPolicy);
                        holdingsService.Update(h);
                        // call check out controller(cur, bc1);
                        t.AddDays(1);
                        n = t;
                    }
                    else // not checking out book already cked out by other patron
                    {
                        // otherwise ignore, already checked out by this patron
                    }
                }
            }
            else
            {
                if (cur != NoPatron) // check in book
                {
                    h.CheckOut(cts, cur, CheckoutPolicies.BookCheckoutPolicy);
                    holdingsService.Update(h);
                }
                else
                {
                    throw new CheckoutException();
                }
            }
        }
示例#10
0
 public static Holding FindByBarcode(IRepository <Holding> repo, string barcode)
 {
     return(FindByClassificationAndCopy(repo, Holding.ClassificationFromBarcode(barcode), Holding.CopyNumberFromBarcode(barcode)));
 }
示例#11
0
 public void ClassificationFromBarcode()
 {
     Assert.That(Holding.ClassificationFromBarcode("QA234:3"), Is.EqualTo("QA234"));
 }