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 EditAsync_ShouldSuccessfullyEdit() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var asphaltMixtureService = new AsphaltMixtureService(context); var editAsphaltMixtureServiceModel = new EditAsphaltMixtureServiceModel(); var asphaltMixtureId = 1; var asphaltMixtureType = "AMT 3"; editAsphaltMixtureServiceModel.Id = asphaltMixtureId; editAsphaltMixtureServiceModel.Type = asphaltMixtureType; await asphaltMixtureService.EditAsync(editAsphaltMixtureServiceModel); var expectedResult = asphaltMixtureType; var actualResult = asphaltMixtureService .All() .First() .Type; Assert.True(expectedResult == actualResult); }
public void All_ShouldReturnEmptyResult() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var asphaltMixtureService = new AsphaltMixtureService(context); var actualResult = asphaltMixtureService.All(); Assert.True(actualResult.Count() == 0); }
public async Task All_ShouldReturnCorrectResult() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var asphaltMixtureService = new AsphaltMixtureService(context); var actualResult = asphaltMixtureService.All().Select(x => x.Type).ToList(); var expectedResult = this.GetDummyData().Select(x => x.Type).ToList(); for (int i = 0; i < actualResult.Count; i++) { Assert.True(expectedResult[i] == actualResult[i]); } }
public async Task CreateAsync_ShouldSuccessfullyCreate() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var asphaltMixtureService = new AsphaltMixtureService(context); var createAsphaltMixtureServiceModel = new CreateAsphaltMixtureServiceModel(); var asphaltMixtureType = "AMT 1"; createAsphaltMixtureServiceModel.Type = asphaltMixtureType; await asphaltMixtureService.CreateAsync(createAsphaltMixtureServiceModel); var expectedResult = asphaltMixtureType; var actualResult = asphaltMixtureService .All() .First() .Type; Assert.True(expectedResult == actualResult); }