public async Task UpdateCarHelpEntry_Invoke() { var carHelpEntry = new CarHelpEntry { Id = Guid.NewGuid() }; var dto = new UpdateCarHelpEntryRequestDto { CarHelpId = carHelpEntry.Id.ToString(), Description = "test" }; var carHelpEntries = new List <CarHelpEntry> { carHelpEntry }.AsQueryable(); var mockCarSet = FakeDbSetFactory <CarHelpEntry> .Get(carHelpEntries); _fakeDb.Setup(m => m.GetSet <CarHelpEntry>()).Returns(mockCarSet.Object); _sut = new CarHelpEntryService(_fakeDb.Object); await _sut.UpdateCarHelpEntry(dto); _fakeDb.Verify(v => v.GetSet <CarHelpEntry>()); _fakeDb.Verify(v => v.SaveDbAsync()); carHelpEntry.Description.Should().Be(dto.Description); }
public async Task GetCarHelpEntries_Invoke() { var carHelpEntry = new CarHelpEntry { Id = Guid.NewGuid() }; var carHelpEntry2 = new CarHelpEntry { Id = Guid.NewGuid() }; var carHelpEntries = new List <CarHelpEntry> { carHelpEntry, carHelpEntry2 }.AsQueryable(); var mockCarSet = FakeDbSetFactory <CarHelpEntry> .Get(carHelpEntries); _fakeDb.Setup(m => m.GetSet <CarHelpEntry>()).Returns(mockCarSet.Object); _sut = new CarHelpEntryService(_fakeDb.Object); var result = await _sut.GetCarHelpEntries(); result.TotalCount.Should().Be(2); }
public async Task UpdateCar_Invoke() { var car = new Car { Id = Guid.NewGuid(), Description = "test", Model = "test" }; var dto = new UpdateCarRequestDto { Id = car.Id.ToString(), Description = "edited_desc", Model = "edited" }; var cars = new List <Car> { car }.AsQueryable(); var mockCarSet = FakeDbSetFactory <Car> .Get(cars); _fakeDb.Setup(m => m.GetSet <Car>()).Returns(mockCarSet.Object); _sut = new CarService(_fakeDb.Object); await _sut.UpdateCar(dto); _fakeDb.Verify(v => v.GetSet <Car>()); _fakeDb.Verify(v => v.SaveDbAsync()); car.Model.Should().Be(dto.Model); car.Description.Should().Be(dto.Description); }
public async Task GetCars_Invoke() { var car = new Car { Id = Guid.NewGuid(), Description = "test", Model = "test" }; var car2 = new Car { Id = Guid.NewGuid(), Description = "test2", Model = "tes2t" }; var cars = new List <Car> { car, car2 }.AsQueryable(); var mockCarSet = FakeDbSetFactory <Car> .Get(cars); _fakeDb.Setup(m => m.GetSet <Car>()).Returns(mockCarSet.Object); _sut = new CarService(_fakeDb.Object); var result = await _sut.GetCars(); result.TotalCount.Should().Be(2); }
public async Task CreateCarHelpEntry_Invoke() { var dto = new CreateCarHelpEntryRequestDto { Description = "test", CarId = Guid.NewGuid().ToString() }; var cars = new List <CarHelpEntry>().AsQueryable(); var mockCarHelpEntrySet = FakeDbSetFactory <CarHelpEntry> .Get(cars); _fakeDb.Setup(m => m.GetSet <CarHelpEntry>()).Returns(mockCarHelpEntrySet.Object); _sut = new CarHelpEntryService(_fakeDb.Object); await _sut.CreateCarHelpEntry(dto); _fakeDb.Verify(v => v.GetSet <CarHelpEntry>()); _fakeDb.Verify(v => v.SaveDbAsync()); }
public async Task CreateCar_Invoke() { var dto = new CreateCarRequestDto { Description = "test", Model = "test", User = null }; var cars = new List <Car>().AsQueryable(); var mockCarSet = FakeDbSetFactory <Car> .Get(cars); _fakeDb.Setup(m => m.GetSet <Car>()).Returns(mockCarSet.Object); _sut = new CarService(_fakeDb.Object); await _sut.CreateCar(dto); _fakeDb.Verify(v => v.GetSet <Car>()); _fakeDb.Verify(v => v.SaveDbAsync()); }