예제 #1
0
        public async Task GetAll_WithData_WorksCorrectly()
        {
            // Arrange
            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            context.CarManufacturers.AddRange(
                new CarManufacturer
            {
                Name = "Manufacturer1"
            },
                new CarManufacturer
            {
                Name = "Manufacturer2"
            });

            context.SaveChanges();

            var manufacturersService = new ManufacturersService(new EfRepository <CarManufacturer>(context));

            // Act
            var actualResult = (await manufacturersService.GetAllAsync()).Count();

            // Assert
            const int expectedResult = 2;

            Assert.Equal(expectedResult, actualResult);
        }
예제 #2
0
        public async Task GetAll_WithNoData_ReturnsEmptyEnumerable()
        {
            // Arrange
            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            var manufacturersService = new ManufacturersService(new EfRepository <CarManufacturer>(context));

            // Act
            var actualResult = (await manufacturersService.GetAllAsync()).Count();

            // Assert
            const int expectedResult = 0;

            Assert.Equal(expectedResult, actualResult);
        }