Exemple #1
0
        public void Throw_WhenIdIsInvalid()
        {
            var options = Utils.GetOptions(nameof(Throw_WhenIdIsInvalid));

            using (var assertContext = new BeerOverflowContext(options))
            {
                var sut = new BeerTypeServices(assertContext);
                Assert.ThrowsException <ArgumentNullException>(() => sut.GetBeerType(1));
            }
        }
Exemple #2
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);
            }
        }
Exemple #3
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);
            }
        }