[Test] // behaviour public void Update_When_entity_is_updated_Then_it_makes_calls_to_repository_and_unit_of_work() { // Arrange var planeTypeDTOToUpdate = new PlaneTypeDTO() { Id = 3, Model = "AAABBBCCC", Seats = 500, Carrying = 400 }; var planeTypeRepositoryFake = A.Fake <IPlaneTypeRepository>(); var unitOfWorkFake = A.Fake <IUnitOfWork>(); A.CallTo(() => unitOfWorkFake.Set <PlaneType>()).Returns(planeTypeRepositoryFake); var planeTypeService = new PlaneTypeService(unitOfWorkFake, AlwaysValidValidator); // Act var result = planeTypeService.Update(planeTypeDTOToUpdate); // Assert A.CallTo(() => planeTypeRepositoryFake.Update(A <PlaneType> ._)).MustHaveHappenedOnceExactly(); A.CallTo(() => unitOfWorkFake.Set <PlaneType>()).MustHaveHappenedOnceExactly(); A.CallTo(() => unitOfWorkFake.SaveChanges()).MustHaveHappenedOnceExactly(); }
public async Task SubmitEdit(int id, string model, int places, int carCap) { Model.PlaneType temp = new Model.PlaneType(); temp.Model = model; temp.Places = (places); temp.CarryCapacity = (carCap); await pts.Update(id, temp); this.Frame.Navigate(typeof(PlaneType)); }
public void Update_When_entity_is_updated_Then_updated_entity_is_returned() { // Arrange var planeTypeMock = new PlaneType() { Id = 3, Model = "AAABBBCCC", Seats = 500, Carrying = 400 }; var planeTypeDTOToUpdate = new PlaneTypeDTO() { Id = 3, Model = "AAABBBCCC", Seats = 500, Carrying = 400 }; var expectedPlaneTypeDTO = new PlaneTypeDTO() { Id = 3, Model = "AAABBBCCC", Seats = 500, Carrying = 400 }; var planeTypeRepositoryFake = A.Fake <IPlaneTypeRepository>(); A.CallTo(() => planeTypeRepositoryFake.Update(A <PlaneType> ._)).Returns(planeTypeMock); var unitOfWorkFake = A.Fake <IUnitOfWork>(); A.CallTo(() => unitOfWorkFake.Set <PlaneType>()).Returns(planeTypeRepositoryFake); var planeTypeService = new PlaneTypeService(unitOfWorkFake, AlwaysValidValidator); // Act var result = planeTypeService.Update(planeTypeDTOToUpdate); // Assert Assert.AreEqual(expectedPlaneTypeDTO.Id, result.Id); Assert.AreEqual(expectedPlaneTypeDTO.Model, result.Model); Assert.AreEqual(expectedPlaneTypeDTO.Seats, result.Seats); Assert.AreEqual(expectedPlaneTypeDTO.Carrying, result.Carrying); }
public void Update_When_entity_is_invalid_Then_bad_request_exception_is_thrown() { // Arrange var planeTypeDTOToUpdate = new PlaneTypeDTO() { Id = 3, Model = "AAABBBCCC", Seats = 500, Carrying = 400 }; var planeTypeRepositoryFake = A.Fake <IPlaneTypeRepository>(); var unitOfWorkFake = A.Fake <IUnitOfWork>(); var planeTypeService = new PlaneTypeService(unitOfWorkFake, AlwaysInValidValidator); // Act + Assert var exception = Assert.Throws <BadRequestException>(() => planeTypeService.Update(planeTypeDTOToUpdate), ""); Assert.AreEqual(exception.Message, "Is Invalid"); }
[Test] //behavior test public void Update_When_entity_is_invalid_Then_it_makes_no_calls_to_repository_and_unit_of_work() { // Arrange var planeTypeDTOToUpdate = new PlaneTypeDTO() { Id = 3, Model = "AAABBBCCC", Seats = 500, Carrying = 400 }; var planeTypeRepositoryFake = A.Fake <IPlaneTypeRepository>(); var unitOfWorkFake = A.Fake <IUnitOfWork>(); var planeTypeService = new PlaneTypeService(unitOfWorkFake, AlwaysInValidValidator); // Act + Assert var exception = Assert.Throws <BadRequestException>(() => planeTypeService.Update(planeTypeDTOToUpdate)); A.CallTo(() => planeTypeRepositoryFake.Update(A <PlaneType> ._)).MustNotHaveHappened(); A.CallTo(() => unitOfWorkFake.PlaneTypeRepository).MustNotHaveHappened(); A.CallTo(() => unitOfWorkFake.Set <PlaneType>()).MustNotHaveHappened(); A.CallTo(() => unitOfWorkFake.SaveChanges()).MustNotHaveHappened(); }
async void Update() { await _planeTypeService.Update(PlaneType); await LoadPlaneTypes().ConfigureAwait(false); }
async void Update() { await PlaneTypeservice.Update(PlaneType); await LoadEntity().ConfigureAwait(false); }