public void DeleteAddress_Action_Fails() { // Arrange var addressDto = TestHelper.AddressDto(); GenericServiceResponse <bool> fakeResponse = null; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.AddressService.DeleteAddress(addressDto)).Returns(fakeResponse).Verifiable(); var viewModel = new GenericViewModel(); var action = new DeleteAddress <GenericViewModel>(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(addressDto); // 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); }
protected void Item_Command(object sender, CommandEventArgs e) { int index; switch (e.CommandName) { case "edit": EditItemIndex = Convert.ToInt32(e.CommandArgument); EditAddress?.Invoke(this, new EditAddressEventArgs() { ItemIndex = EditItemIndex, AddressID = GetAddressID(EditItemIndex) }); break; case "cancel": EditItemIndex = -1; EditAddress?.Invoke(this, new EditAddressEventArgs() { ItemIndex = EditItemIndex, AddressID = 0 }); break; case "update": var item = GetUpdateItem(); index = EditItemIndex; EditItemIndex = -1; UpdateAddress?.Invoke(this, new UpdateAddressEventArgs() { ItemIndex = index, Item = item }); break; case "delete": index = Convert.ToInt32(e.CommandArgument); EditItemIndex = -1; DeleteAddress?.Invoke(this, new EditAddressEventArgs() { ItemIndex = index, AddressID = GetAddressID(index) }); break; } }