Ejemplo n.º 1
0
        public void GetAuthorOrDirectorReturnsForBookOrVideo()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <ILSContext>()
                          .UseInMemoryDatabase(databaseName: "GetAuthorOrDirectorReturnsForBookOrVideo")
                          .Options;

            using (var context = new ILSContext(options))
            {
                context.LibraryAsset.Add(new LibraryAsset
                {
                    Discriminator  = "Book",
                    Title          = "The Republic",
                    Author         = "Plato",
                    DeweyIndex     = "820.119",
                    ISBN           = "9780758320209",
                    Year           = -380,
                    Cost           = 11,
                    ImageUrl       = "/images/republic.png",
                    NumberOfCopies = 2,
                    LocationId     = 2,
                    StatusId       = 2
                });

                context.LibraryAsset.Add(new LibraryAsset
                {
                    Discriminator  = "Video",
                    Title          = "The Matrix",
                    Director       = "Lana / Lilly Wachowski",
                    Year           = 1999,
                    Cost           = 15,
                    ImageUrl       = "/images/thematrix.png",
                    NumberOfCopies = 2,
                    LocationId     = 1,
                    StatusId       = 1
                });

                context.SaveChanges();
            }

            string video;
            string book;

            // Act
            using (var context = new ILSContext(options))
            {
                var libraryAssetService = new LibraryAssetService(context);
                book  = libraryAssetService.GetAuthorOrDirector(1);
                video = libraryAssetService.GetAuthorOrDirector(2);
            }

            // Assert
            Assert.IsNotNull(video);
            Assert.IsNotNull(book);
            Assert.AreEqual(video, "Lana / Lilly Wachowski");
            Assert.AreEqual(book, "Plato");
        }
Ejemplo n.º 2
0
        public void GetDeweyIndexReturnsCorrectIndex()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <ILSContext>()
                          .UseInMemoryDatabase(databaseName: "GetDeweyIndexReturnsCorrectIndex")
                          .Options;

            using (var context = new ILSContext(options))
            {
                context.LibraryAsset.Add(new LibraryAsset
                {
                    Discriminator  = "Book",
                    Title          = "The Republic",
                    Author         = "Plato",
                    DeweyIndex     = "820.119",
                    ISBN           = "9780758320209",
                    Year           = -380,
                    Cost           = 11,
                    ImageUrl       = "/images/republic.png",
                    NumberOfCopies = 2,
                    LocationId     = 2,
                    StatusId       = 2
                });

                context.LibraryAsset.Add(new LibraryAsset
                {
                    Discriminator  = "Book",
                    Title          = "Jane Eyre",
                    Author         = "Charlotte Brontë",
                    DeweyIndex     = "822.133",
                    ISBN           = "9781519133977",
                    Year           = 1847,
                    Cost           = 15,
                    ImageUrl       = "/images/janeeyre.png",
                    NumberOfCopies = 5,
                    LocationId     = 1,
                    StatusId       = 1
                });

                context.SaveChanges();
            }

            string result;

            // Act
            using (var context = new ILSContext(options))
            {
                var libraryAssetService = new LibraryAssetService(context);
                result = libraryAssetService.GetDeweyIndex(2);
            }

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("822.133", result);
        }
Ejemplo n.º 3
0
 public BranchService(ILSContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 public OrganizationTypesController(ILSContext context)
 {
     _context = context;
 }
Ejemplo n.º 5
0
 public PatronService(ILSContext context)
 {
     _context = context;
 }
 public PlacesController(ILSContext context)
 {
     _context = context;
 }
Ejemplo n.º 7
0
 public CheckoutService(ILSContext context)
 {
     _context = context;
 }
Ejemplo n.º 8
0
 public CommsService(ILSContext context)
 {
     _context = context;
 }
Ejemplo n.º 9
0
        public void GetAllReturnsLibraryAssets()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <ILSContext>()
                          .UseInMemoryDatabase(databaseName: "GetAllReturnsLibraryAssets")
                          .Options;

            using (var context = new ILSContext(options))
            {
                context.LibraryAsset.Add(new LibraryAsset
                {
                    Discriminator  = "Book",
                    Title          = "The Republic",
                    Author         = "Plato",
                    DeweyIndex     = "820.119",
                    ISBN           = "9780758320209",
                    Year           = -380,
                    Cost           = 11,
                    ImageUrl       = "/images/republic.png",
                    NumberOfCopies = 2,
                    Location       = new BranchDetails {
                        Name = "Branch A"
                    },
                    Status = new Status {
                        Name = "Available", Description = "Available"
                    },
                    LibraryCard = new LibraryCard {
                    }
                });

                context.LibraryAsset.Add(new LibraryAsset
                {
                    Discriminator  = "Book",
                    Title          = "Jane Eyre",
                    Author         = "Charlotte Brontë",
                    DeweyIndex     = "822.133",
                    ISBN           = "9781519133977",
                    Year           = 1847,
                    Cost           = 15,
                    ImageUrl       = "/images/janeeyre.png",
                    NumberOfCopies = 5,
                    LocationId     = 1,
                    StatusId       = 1
                });

                context.SaveChanges();
            }

            IEnumerable <LibraryAsset> result;
            int count;

            // Act
            using (var context = new ILSContext(options))
            {
                var libraryAssetService = new LibraryAssetService(context);
                result = libraryAssetService.GetAll();
                count  = result.Count();
            }

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(count, 2);
        }