コード例 #1
0
        public async Task ReturnTrue_When_ParamsAreValid()
        {
            var options      = TestUtils.GetOptions(nameof(ReturnTrue_When_ParamsAreValid));
            var mockDateTime = new Mock <IDateTimeProvider>();
            var brewery      = new Brewery
            {
                Name = "Zagorka"
            };

            using (var arrangeContext = new BeeroverflowContext(options))
            {
                await arrangeContext.Breweries.AddAsync(brewery);

                await arrangeContext.SaveChangesAsync();
            }

            //Act and Assert
            using (var assertContext = new BeeroverflowContext(options))
            {
                var sut = new BreweryService(assertContext, mockDateTime.Object);
                await sut.DeleteBreweryAsync(1);

                var result = assertContext.Breweries.Where(x => x.Id == 1).FirstOrDefault();
                Assert.IsTrue(result.isDeleted);
            }
        }
コード例 #2
0
        public async Task ReturnFalse_When_ParamsAreInValid()
        {
            var options      = TestUtils.GetOptions(nameof(ReturnFalse_When_ParamsAreInValid));
            var mockDateTime = new Mock <IDateTimeProvider>();

            //Act and Assert
            using (var assertContext = new BeeroverflowContext(options))
            {
                var sut = new BreweryService(assertContext, mockDateTime.Object);

                await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.DeleteBreweryAsync(1));
            }
        }