Пример #1
0
        public async Task GetAsync_ShouldReturnBreweryDTOAsync()
        {
            //Arrange
            var options = InMemory.GetOptions("GetAsync_ShouldReturnBreweryDTOAsync");

            using (var context = new BOContext(options))
            {
                var country = new Country()
                {
                    Name      = "Bulgaria",
                    Breweries = new List <Brewery>()
                    {
                        new Brewery()
                        {
                            Name  = "Brewery",
                            Beers = new List <Beer>()
                        }
                    }
                };
                context.Countries.Add(country);
                await context.SaveChangesAsync();
            }

            using (var context = new BOContext(options))
            {
                //Act
                var sut    = new BreweryServices(context);
                var result = await sut.GetAsync(1);

                //Assert
                Assert.IsInstanceOfType(result, typeof(BreweryDTO));;
            }
        }
Пример #2
0
        public async Task GetAsync_ShouldReturnNullIfBreweryIdNullAsync()
        {
            //Arrange
            var options = InMemory.GetOptions("GetAsync_ShouldReturnNullIfBreweryIdNullAsync");

            using (var context = new BOContext(options))
            {
            }

            using (var context = new BOContext(options))
            {
                //Act
                var sut    = new BreweryServices(context);
                var result = await sut.GetAsync(null);

                //Assert
                Assert.AreEqual(result, null);
            }
        }
Пример #3
0
        public async Task GetAsync_ShouldReturnNullIfBreweryModelConversionFailsAsync()
        {
            //Arrange
            var options = InMemory.GetOptions("GetAsync_ShouldReturnNullIfBreweryModelConversionFailsAsync");

            using (var context = new BOContext(options))
            {
                var brewery = new Brewery();
                context.Breweries.Add(brewery);
                await context.SaveChangesAsync();
            }

            using (var context = new BOContext(options))
            {
                //Act
                var sut    = new BreweryServices(context);
                var result = await sut.GetAsync(1);

                //Assert
                Assert.AreEqual(result, null);
            }
        }