public void DeleteCity_Action_Fails() { // Arrange var cityDto = TestHelper.CityDto(); GenericServiceResponse <bool> fakeResponse = null; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.CityService.DeleteCity(cityDto)).Returns(fakeResponse).Verifiable(); var viewModel = new GenericViewModel(); var action = new DeleteCity <GenericViewModel>(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(cityDto); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(GenericViewModel)); Assert.IsNotNull(result.Notifications); Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection)); Assert.IsTrue(result.Notifications.Count() == 1); Assert.IsTrue(result.HasErrors); Assert.IsNotNull(result.Success); Assert.IsInstanceOfType(result.Success, typeof(bool)); Assert.IsFalse(result.Success); }
public Task Handle(object command) { return(command switch { Create cmd => HandleCreate(cmd), SetCityName cmd => HandleUpdate(cmd.Id, c => c.UpdateCityName(cmd.Name)), DeleteCity cmd => HandleUpdateAsync(cmd.Id, _ => this._repository.RemoveAsync(cmd.Id)), _ => Task.CompletedTask });
public IApiResult Delete(DeleteCity operation) { var result = operation.ExecuteAsync().Result; if (result is ValidationsOutput) { return(new ApiResult <List <ValidationItem> >() { Data = ((ValidationsOutput)result).Errors }); } else { return(new ApiResult <object>() { Status = ApiResult <object> .ApiStatus.Success }); } }
private void BtnDeleteCity_OnClick(object sender, RoutedEventArgs e) { AdminLoggedIn currentWindow = this; DeleteCity window = new DeleteCity(ref currentWindow); window.ShowDialog(); }