Beispiel #1
0
        public async Task ReturnFalse_WhenIndustryAlreadyDeleted()
        {
            //Arrange
            var options  = Utils.GetOptions(nameof(ReturnFalse_WhenIndustryAlreadyDeleted));
            var industry = TestModelsSeeder.SeedIndustry();

            industry.IsDeleted = true;

            using (var arrangeContext = new InsightHubContext(options))
            {
                await arrangeContext.Industries.AddAsync(industry);

                await arrangeContext.SaveChangesAsync();
            }
            //Act & Assert
            using var assertContext = new InsightHubContext(options);
            var sut = new IndustryServices(assertContext);
            await Assert.ThrowsExceptionAsync <ArgumentException>(async() => await sut.DeleteIndustry(industry.Id));
        }
Beispiel #2
0
        public async Task SetDeletedFlag_WhenParamsAreValid()
        {
            //Arrange
            var options  = Utils.GetOptions(nameof(SetDeletedFlag_WhenParamsAreValid));
            var industry = TestModelsSeeder.SeedIndustry();

            using (var arrangeContext = new InsightHubContext(options))
            {
                await arrangeContext.Industries.AddAsync(industry);

                await arrangeContext.SaveChangesAsync();
            }
            //Act & Assert
            using var assertContext = new InsightHubContext(options);
            var sut = new IndustryServices(assertContext);
            await sut.DeleteIndustry(1);

            var result = await assertContext.Industries.FirstOrDefaultAsync(i => i.Name == industry.Name);

            Assert.IsTrue(result.IsDeleted);
        }
Beispiel #3
0
        public async Task Throw_WhenIdIsInvalid()
        {
            //Arrange
            var options = Utils.GetOptions(nameof(Throw_WhenIdIsInvalid));

            //Act & Assert
            using var assertContext = new InsightHubContext(options);
            var sut = new IndustryServices(assertContext);
            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await sut.DeleteIndustry(5));
        }