Ejemplo n.º 1
0
        public void ReturnCorrectList_WhenDataIsPresent()
        {
            var options   = Utils.GetOptions(nameof(ReturnCorrectList_WhenDataIsPresent));
            var beerType1 = TestsModelsSeeder.SeedBeerType();
            var beerType2 = TestsModelsSeeder.SeedBeerType2();
            var beerType3 = TestsModelsSeeder.SeedBeerType3();

            using (var arrangeContext = new BeerOverflowContext(options))
            {
                arrangeContext.BeerTypes.Add(beerType1);
                arrangeContext.BeerTypes.Add(beerType2);
                arrangeContext.BeerTypes.Add(beerType3);
                arrangeContext.SaveChanges();
            }

            using (var assertContext = new BeerOverflowContext(options))
            {
                var sut    = new BeerTypeServices(assertContext);
                var result = sut.GetAllBeerTypes().ToList();
                Assert.AreEqual(3, result.Count);
                Assert.AreEqual(beerType1.Name, result[0].Name);
                Assert.AreEqual(beerType2.Name, result[1].Name);
                Assert.AreEqual(beerType3.Name, result[2].Name);
            }
        }
Ejemplo n.º 2
0
        public void Throw_WhenBeerTypeIdIsInvalid()
        {
            var options   = Utils.GetOptions(nameof(Throw_WhenBeerTypeIdIsInvalid));
            var beerType1 = TestsModelsSeeder.SeedBeerType();
            var beerType2 = TestsModelsSeeder.SeedBeerType2();

            using (var arrangeContext = new BeerOverflowContext(options))
            {
                arrangeContext.BeerTypes.Add(beerType1);
                arrangeContext.BeerTypes.Add(beerType2);
                arrangeContext.SaveChanges();
            }

            using (var assertContext = new BeerOverflowContext(options))
            {
                var sut = new BeerTypeServices(assertContext);
                Assert.ThrowsException <ArgumentNullException>(() => sut.UpdateBeerType(5, "newBeerType"));
            }
        }
Ejemplo n.º 3
0
        public void CorrectlyUpdateBeerType_WhenDataIsValid()
        {
            var options   = Utils.GetOptions(nameof(CorrectlyUpdateBeerType_WhenDataIsValid));
            var beerType1 = TestsModelsSeeder.SeedBeerType();
            var beerType2 = TestsModelsSeeder.SeedBeerType2();

            using (var arrangeContext = new BeerOverflowContext(options))
            {
                arrangeContext.BeerTypes.Add(beerType1);
                arrangeContext.BeerTypes.Add(beerType2);
                arrangeContext.SaveChanges();
            }

            using (var assertContext = new BeerOverflowContext(options))
            {
                var sut    = new BeerTypeServices(assertContext);
                var act    = sut.UpdateBeerType(2, "newBeerType");
                var result = sut.GetBeerType(2);
                Assert.AreEqual("newBeerType", result.Name);
            }
        }
Ejemplo n.º 4
0
        public void ReturnCorrectBeerType_WhenIdIsValid()
        {
            var options   = Utils.GetOptions(nameof(ReturnCorrectBeerType_WhenIdIsValid));
            var beerType1 = TestsModelsSeeder.SeedBeerType();
            var beerType2 = TestsModelsSeeder.SeedBeerType2();

            using (var arrangeContext = new BeerOverflowContext(options))
            {
                arrangeContext.BeerTypes.Add(beerType1);
                arrangeContext.BeerTypes.Add(beerType2);
                arrangeContext.SaveChanges();
            }

            using (var assertContext = new BeerOverflowContext(options))
            {
                var sut    = new BeerTypeServices(assertContext);
                var result = sut.GetBeerType(2);
                Assert.AreEqual(beerType2.Id, result.Id);
                Assert.AreEqual(beerType2.Name, result.Name);
            }
        }