public static void CheckOut(this ScanStation scanner, string barcode, int patronId, DateTime dateTime)
 {
     TimeService.NextTime = dateTime;
     scanner.AcceptLibraryCard(patronId);
     TimeService.NextTime = dateTime;
     scanner.AcceptBarcode(barcode);
 }
        public void CheckInAtSecondBranchResultsInTransfer()
        {
            var newBranchId    = scanner.BranchId + 1;
            var scannerBranch2 = new ScanStation(context, newBranchId, classificationService, holdingsService, patronsService);

            scannerBranch2.AcceptBarcode(SomeBarcode);

            Assert.Equal(newBranchId, holdingsService.FindByBarcode(SomeBarcode).BranchId);
        }
Beispiel #3
0
            public void CheckInAtSecondBranchResultsInTransfer()
            {
                var newBranchId    = scanner.BranchId + 1;
                var scannerBranch2 = new ScanStation(newBranchId, classificationService.Object, holdingRepo, patronRepo);

                scannerBranch2.AcceptBarcode(SomeBarcode);

                Assert.That(GetByBarcode(SomeBarcode).BranchId, Is.EqualTo(newBranchId));
            }
        public void TransfersAreCheckinsToDifferentBranch()
        {
            CheckOut(barcode1);

            var scannerBranch2 = new ScanStation(Branch2Id, classificationService);

            scannerBranch2.AcceptBarcode(barcode1);

            var holding = holdingService.Retrieve(barcode1);

            Assert.That(holding.IsCheckedOut, Is.False);
            Assert.That(holding.BranchId, Is.EqualTo(Branch2Id));
        }
Beispiel #5
0
        public void Initialize()
        {
            holdingRepo           = new InMemoryRepository <Holding>();
            patronRepo            = new InMemoryRepository <Patron>();
            classificationService = new Mock <IClassificationService>();
            AlwaysReturnBookMaterial(classificationService);
            somePatronId = patronRepo.Create(new Patron {
                Name = "x"
            });

            // calling .Object on a mock for the first time is an expensive operation (~200+ ms)
            scanner = new ScanStation(1, classificationService.Object, holdingRepo, patronRepo);
        }
        public ScanStation_WhenNewMaterialCheckedOutTest(DbContextFixture fixture)
        {
            fixture.Seed();
            context         = new LibraryContext(fixture.ContextOptions);
            holdingsService = new HoldingsService(context);
            patronsService  = new PatronsService(context);

            classificationServiceMock = new Mock <IClassificationService>();
            classificationService     = classificationServiceMock.Object;

            scanner = new ScanStation(context, 1, classificationService, holdingsService, patronsService);

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

            CheckOutNewMaterial();
        }
        public ScanStation_WhenNothingCheckedOutTest(DbContextFixture fixture)
        {
            fixture.Seed();
            context         = new LibraryContext(fixture.ContextOptions);
            patronsService  = new PatronsService(context);
            holdingsService = new HoldingsService(context);

            classificationServiceMock = new Mock <IClassificationService>();
            classificationService     = classificationServiceMock.Object;
            AlwaysReturnBookMaterial(classificationServiceMock);

            somePatronId = patronsService.Create(new Patron {
                Name = "x"
            });

            scanner = new ScanStation(context, 1, classificationService, new HoldingsService(context),
                                      new PatronsService(context));
        }
        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);
        }
        public void Initialize()
        {
            classificationService = new StubClassificationService();
            classificationService.AddBook(Classification1, "T1", "A1", "2001");
            classificationService.AddBook(Classification2, "T2", "A2", "2002");

            scanner = new ScanStation(Branch1Id, classificationService);

            holdingService = new HoldingService();
            holdingService.DeleteAllHoldings();

            patronService = new PatronService();
            PatronService.DeleteAllPatrons();

            patronId1 = patronService.Add("Joe");
            patronId2 = patronService.Add("Jane");

            var holding = scanner.AddNewMaterial(Isbn1);

            Assert.That(holding.Barcode, Is.EqualTo(barcode1));
        }
        public ScanStation_WhenMaterialCheckedInTest(DbContextFixture fixture)
        {
            fixture.Seed();
            context         = new LibraryContext(fixture.ContextOptions);
            patronsService  = new PatronsService(context);
            holdingsService = new HoldingsService(context);

            classificationServiceMock = new Mock <IClassificationService>();
            classificationService     = classificationServiceMock.Object;

            somePatronId = patronsService.Create(new Patron {
                Name = "x"
            });

            scanner = new ScanStation(context, 1, classificationService, holdingsService, patronsService);

            scanner.ScanNewMaterial(SomeBarcode, classificationServiceMock);
            scanner.CheckOut(SomeBarcode, somePatronId, now);
            scanner.CompleteCheckout();
            scanner.CheckIn(SomeBarcode, now);
        }
 public static void CheckIn(this ScanStation scanner, string barcode, DateTime dateTime)
 {
     TimeService.NextTime = dateTime;
     scanner.AcceptBarcode(barcode);
 }