Beispiel #1
0
        public async Task ReturnNotDeletedIndustries_WithSearch_When_ParamValid()
        {
            //Arrange
            var options   = Utils.GetOptions(nameof(ReturnNotDeletedIndustries_WithSearch_When_ParamValid));
            var industry  = TestModelsSeeder.SeedIndustry();
            var industry2 = TestModelsSeeder.SeedIndustry2();
            var industry3 = TestModelsSeeder.SeedIndustry3();

            industry.IsDeleted = true;

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

                await arrangeContext.Industries.AddAsync(industry2);

                await arrangeContext.Industries.AddAsync(industry3);

                await arrangeContext.SaveChangesAsync();
            }
            //Act & Assert
            using var assertContext = new InsightHubContext(options);
            var sut    = new IndustryServices(assertContext);
            var result = (await sut.GetAllIndustries(null, "3")).ToArray();

            Assert.AreEqual(1, result.Length);
            Assert.AreEqual(industry3.Name, result[0].Name);
        }
Beispiel #2
0
        public async Task ReturnNotDeletedIndustries()
        {
            //Arrange
            var options   = Utils.GetOptions(nameof(ReturnNotDeletedIndustries));
            var industry  = TestModelsSeeder.SeedIndustry();
            var industry2 = TestModelsSeeder.SeedIndustry2();
            var industry3 = TestModelsSeeder.SeedIndustry3();

            industry.IsDeleted = true;

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

                await arrangeContext.Industries.AddAsync(industry2);

                await arrangeContext.Industries.AddAsync(industry3);

                await arrangeContext.SaveChangesAsync();
            }
            //Act & Assert
            using var assertContext = new InsightHubContext(options);
            var sut    = new IndustryServices(assertContext);
            var result = await sut.GetAllIndustries(null, null);

            Assert.AreEqual(2, result.Count);
        }