public async Task DeleteByIdAsync_ShouldSuccessfullyDelete() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var driverService = new DriverService(context); var deleteDriverServiceModel = new DeleteDriverServiceModel(); deleteDriverServiceModel.Id = 1; await driverService.DeleteByIdAsync(deleteDriverServiceModel.Id); var expectedResult = 1; var actualResult = driverService .All() .Count(); var expectedResult2 = "DFN 2"; var actualResult2 = driverService .All() .First() .FullName; Assert.True(expectedResult == actualResult); Assert.True(expectedResult2 == actualResult2); }
public async Task EditAsync_ShouldSuccessfullyEdit() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var driverService = new DriverService(context); var editDriverServiceModel = new EditDriverServiceModel(); var driverId = 1; var driverFullName = "DFN 3"; editDriverServiceModel.Id = driverId; editDriverServiceModel.FullName = driverFullName; await driverService.EditAsync(editDriverServiceModel); var expectedResult = driverFullName; var actualResult = driverService .All() .First() .FullName; Assert.True(expectedResult == actualResult); }
public void All_ShouldReturnEmptyResult() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var driverService = new DriverService(context); var actualResult = driverService.All(); Assert.True(actualResult.Count() == 0); }
public async Task All_ShouldReturnCorrectResult() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var driverService = new DriverService(context); var actualResult = driverService.All().Select(x => x.FullName).ToList(); var expectedResult = this.GetDummyData().Select(x => x.FullName).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 driverService = new DriverService(context); var createDriverServiceModel = new CreateDriverServiceModel(); var driverFullName = "DFN 1"; createDriverServiceModel.FullName = driverFullName; await driverService.CreateAsync(createDriverServiceModel); var expectedResult = driverFullName; var actualResult = driverService .All() .First() .FullName; Assert.True(expectedResult == actualResult); }