public void DeleteBuyerCommand_When_Executed_Send_Message_To_PaymentViewModel_To_Update_BuyerList() { //Arrange _buyerListViewModel = new BuyerListViewModel(_contextMock.Object, _navigationServiceMock.Object); Buyer deletedBuyer = null; var receivedStatus = EntityState.Default; Messenger.Default.Register<MessageService>(this, MessengerToken.PaymentVm, message => { receivedStatus = message.EntityState; deletedBuyer = message.Buyer; }); CreateBuyer(); var buyerToDelete = _store.First(); _buyerListViewModel.SelectedBuyer = buyerToDelete; //Act _buyerListViewModel.DeleteBuyerCommand.Execute(null); //Verify Assert.IsTrue(receivedStatus == EntityState.Deleted); Assert.IsTrue(deletedBuyer.Equals(buyerToDelete)); }
public void DeleteBuyerCommand_Cannot_Execute_When_Buyer_Is_Not_Selected() { //Arrange _buyerListViewModel = new BuyerListViewModel(_contextMock.Object, _navigationServiceMock.Object); _buyerListViewModel.SelectedBuyer = null; //Act and Verify Assert.IsFalse(_buyerListViewModel.DeleteBuyerCommand.CanExecute(null)); }
public void DeleteBuyerCommand_When_Executed_Invokes_DeleteBuyerById() { //Arrange _buyerListViewModel = new BuyerListViewModel(_contextMock.Object, _navigationServiceMock.Object); CreateBuyer(); var buyerToDelete = _store.First(); _buyerListViewModel.SelectedBuyer = buyerToDelete; //Act _buyerListViewModel.DeleteBuyerCommand.Execute(null); //Verify _contextMock.Verify(m => m.People.RemoveById(It.IsAny<int>()), Times.Once); Assert.IsNull(_buyerListViewModel.SelectedBuyer); }
public void DeleteBuyerCommand_When_Executed_Send_Message_To_Update_Status_Bar() { //Arrange _buyerListViewModel = new BuyerListViewModel(_contextMock.Object, _navigationServiceMock.Object); const string expectedStatus = "Nabywca usunięty"; string receivedStatus = null; Messenger.Default.Register<StatusMessage>(this, MessengerToken.MainWindowVm, message => { receivedStatus = message.NewStatus; }); CreateBuyer(); var buyerToDelete = _store.First(); _buyerListViewModel.SelectedBuyer = buyerToDelete; //Act _buyerListViewModel.DeleteBuyerCommand.Execute(null); //Verify Assert.IsTrue(expectedStatus.Equals(receivedStatus)); }
public void When_Initialized_Invoke_GetBuyerListForSeller() { //Arrange and Act _buyerListViewModel = new BuyerListViewModel(_contextMock.Object, _navigationServiceMock.Object); //Verify _contextMock.Verify(m=>m.People.FindBuyers(It.IsAny<Expression<Func<Buyer, bool>>>()),Times.Once); }
public void NavigateToInvoiceCommand_When_Exected_Invoke_NavigateTo_With_InvoiceKey() { //Arrange _buyerListViewModel = new BuyerListViewModel(_contextMock.Object, _navigationServiceMock.Object); //Act _buyerListViewModel.NavigateToInvoiceCommand.Execute(null); //Verify _navigationServiceMock.Verify(m => m.NavigateTo(ViewModelLocator.InvoiceKey), Times.Once); }
public void NavigateToEditBuyerCommand_When_Executed_Invoke_NavigateTo_With_BuyerKey_And_Buyer() { //Arrange _buyerListViewModel = new BuyerListViewModel(_contextMock.Object, _navigationServiceMock.Object); CreateBuyer(); _buyerListViewModel.SelectedBuyer = _store.First(); //Act _buyerListViewModel.NavigateToEditBuyerCommand.Execute(null); //Verify _navigationServiceMock.Verify(m => m.NavigateTo(ViewModelLocator.BuyerKey, It.IsAny<Buyer>()),Times.Once); }