public async Task DeleteByIdAsync_ShouldSuccessfullyDelete() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var asphaltMixtureService = new AsphaltMixtureService(context); var deleteAsphaltMixtureServiceModel = new DeleteAsphaltMixtureServiceModel(); deleteAsphaltMixtureServiceModel.Id = 1; await asphaltMixtureService.DeleteByIdAsync(deleteAsphaltMixtureServiceModel.Id); var expectedResult = 1; var actualResult = asphaltMixtureService .All() .Count(); var expectedResult2 = "AMT 2"; var actualResult2 = asphaltMixtureService .All() .First() .Type; Assert.True(expectedResult == actualResult); Assert.True(expectedResult2 == actualResult2); }
public async Task DeleteByIdAsync_WithNonExistingIdShouldThrowArgumentNullException() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var asphaltMixtureService = new AsphaltMixtureService(context); var deleteAsphaltMixtureServiceModel = new DeleteAsphaltMixtureServiceModel(); deleteAsphaltMixtureServiceModel.Id = 3; await Assert.ThrowsAsync <ArgumentNullException>(async() => { await asphaltMixtureService.DeleteByIdAsync(deleteAsphaltMixtureServiceModel.Id); }); }