public void DeleteInvoiceCommand_Cannot_Execute_When_Selected_Invoice_Is_Null()
        {
            //Arrange
            _invoiceListViewModel = new InvoiceListViewModel(_contextMock.Object, _navigationServiceMock.Object) { SelectedInvoice = null };

            //Act and Verify
            Assert.IsFalse(_invoiceListViewModel.DeleteInvoiceCommand.CanExecute(null));
        }
        public void CreateNewInvoiceBasedOnOldOneCommand_Cannot_Execute_When_SelectedInvoice_Is_Null()
        {
            //Arrange
            _invoiceListViewModel = new InvoiceListViewModel(_contextMock.Object, _navigationServiceMock.Object);

               _invoiceListViewModel.SelectedInvoice = null;

            //Act and Verify
            Assert.IsFalse(_invoiceListViewModel.CreateNewInvoiceBasedOnOldOneCommand.CanExecute(null));
        }
        public void CreateNewInvoiceBasedOnOldOneCommand_When_Executed_Invoke_GetInvoice()
        {
            //Arrange
            _invoiceListViewModel = new InvoiceListViewModel(_contextMock.Object, _navigationServiceMock.Object);
            _invoiceListViewModel.SelectedInvoice = _invoiceDetails.First();

            //Act
            _invoiceListViewModel.CreateNewInvoiceBasedOnOldOneCommand.Execute(null);

            //Verify
            _contextMock.Verify(m => m.Payments.GetInvoice(It.IsAny<int>()), Times.Once);
        }
        public void DeleteInvoiceCommand_When_Executed_Invokes_DeletePaymentById()
        {
            //Arrange
            _invoiceListViewModel = new InvoiceListViewModel(_contextMock.Object, _navigationServiceMock.Object);
            var invoice = GetInvoiceDetails();

            _invoiceListViewModel.SelectedInvoice = invoice;

            //Act
            _invoiceListViewModel.DeleteInvoiceCommand.Execute(null);

            //Verify
            _contextMock.Verify(m => m.Payments.RemoveById(It.IsAny<int>()), Times.Once);
        }
        public void DeleteInvoiceCommand_When_Executed_Send_Message_To_Update_Status_Bar()
        {
            //Arrange
            const string expectedStatus = "Faktura usunięta";
            string receivedStatus = null;

            Messenger.Default.Register<StatusMessage>(this, MessengerToken.MainWindowVm, msg =>
            {
                receivedStatus = msg.NewStatus;
            });

            var invoice = GetInvoiceDetails();
            _invoiceListViewModel = new InvoiceListViewModel(_contextMock.Object, _navigationServiceMock.Object);
            _invoiceListViewModel.SelectedInvoice = invoice;

            //Act
            _invoiceListViewModel.DeleteInvoiceCommand.Execute(null);

            //Verify
            Assert.IsTrue(expectedStatus.Equals(receivedStatus));
        }
        public void When_Initialized_Invoke_GetListOfInvoiceDetailsBySellerId()
        {
            //Arrange
            _navigationServiceMock.SetupGet(m => m.Parameter).Returns(_selectedSeller);

            //Act
            _invoiceListViewModel = new InvoiceListViewModel(_contextMock.Object, _navigationServiceMock.Object);

            //Verify
            _contextMock.Verify(m => m.Payments.GetBasicInvoicesData(_selectedSeller.ID), Times.Once);
        }
        public void NavigateToInvoiceCommand_When_Executed_Invoke_NavigateTo_WIth_InvoiceKey()
        {
            //Arrange
            _invoiceListViewModel = new InvoiceListViewModel(_contextMock.Object, _navigationServiceMock.Object);

            //Act
            _invoiceListViewModel.NavigateToInvoiceCommand.Execute(null);

            //Verify
            _navigationServiceMock.Verify(m => m.NavigateTo(ViewModelLocator.InvoiceKey), Times.Once);
        }
        public void Delete_Invoices_In_InvoiceList_That_Belongs_To_Received_Deleted_Buyer()
        {
            //Arrange
              _invoiceListViewModel = new InvoiceListViewModel(_contextMock.Object, _navigationServiceMock.Object);

            Buyer buyer = _store.First().Buyer;
            Buyer deletedBuyer = buyer;

            //Act
            Messenger.Default.Send(new MessageService(deletedBuyer, EntityState.Deleted), MessengerToken.InvoiceListVm);

            //Verify
            Assert.IsFalse(_invoiceListViewModel.InvoiceList.Any(i => i.BuyerInformation.PersonId == deletedBuyer.ID));
        }