public async Task Throw_WhenIndustryWithNameAlreadyExists() { var options = Utils.GetOptions(nameof(Throw_WhenIndustryWithNameAlreadyExists)); var industry = TestModelsSeeder.SeedIndustry(); var industry2 = TestModelsSeeder.SeedIndustry2(); using (var arrangeContext = new InsightHubContext(options)) { await arrangeContext.AddAsync(industry); await arrangeContext.AddAsync(industry2); await arrangeContext.SaveChangesAsync(); } using var assertContext = new InsightHubContext(options); var sut = new IndustryServices(assertContext); await Assert.ThrowsExceptionAsync <ArgumentException>(() => sut.UpdateIndustry(1, industry2.Name, "testURL")); }
public async Task Throw_WhenIdIsInvalid() { //Arrange var options = Utils.GetOptions(nameof(Throw_WhenIdIsInvalid)); var industry = TestModelsSeeder.SeedIndustry(); using (var arrangeContext = new InsightHubContext(options)) { await arrangeContext.AddAsync(industry); await arrangeContext.SaveChangesAsync(); } //Act & Assert using var assertContext = new InsightHubContext(options); var sut = new IndustryServices(assertContext); await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.UpdateIndustry(5, "NewName", "NewTestURL")); }
public async Task ReturnCorrectIndustry_WhenParamsAreValid() { //Arrange var options = Utils.GetOptions(nameof(ReturnCorrectIndustry_WhenParamsAreValid)); var industry = TestModelsSeeder.SeedIndustry(); using (var arrangeContext = new InsightHubContext(options)) { await arrangeContext.AddAsync(industry); await arrangeContext.SaveChangesAsync(); } //Act & Assert using var assertContext = new InsightHubContext(options); var sut = new IndustryServices(assertContext); var result = await sut.GetIndustry(1); Assert.AreEqual(industry.Id, result.Id); Assert.AreEqual(industry.Name, result.Name); }