Beispiel #1
0
        public InvoiceWindowViewModel(IUnityContainer container, IInvoiceService invoiceService,
                                      ICustomerService customerService, INavigationService navigationService,
                                      INotificationService notificationService)
        {
            this.invoiceService      = invoiceService;
            this.customerService     = customerService;
            this.navigationService   = navigationService;
            this.notificationService = notificationService;

            this.CancelCommand            = new RelayCommand(onCancelExecuted);
            this.SaveInvoiceCommand       = new RelayCommand(onSaveInvoiceExecuted, onSaveInvoiceCanExecute);
            this.InvoiceItemEditedCommand = new RelayCommand(onInvoiceItemEditedExecuted);

            this.invoiceModelViewModel = new InvoiceModelViewModel();
            this.invoiceModelViewModel.PropertyChanged +=
                ((s, e) => this.SaveInvoiceCommand.RaiseCanExecuteChanged());
            this.invoiceModelViewModel.InvoiceItems.CollectionChanged +=
                ((s, e) => this.SaveInvoiceCommand.RaiseCanExecuteChanged());

            this.invoiceModelViewModel.IssueDate = DateTime.Now;
            this.invoiceModelViewModel.DueDate   = DateTime.Now.AddDays(7);

            this.customerSearchBoxViewModel = container.Resolve <CustomerSearchBoxViewModel>();
            this.customerSearchBoxViewModel.PropertyChanged +=
                ((s, e) => this.SaveInvoiceCommand.RaiseCanExecuteChanged());
        }
Beispiel #2
0
        public void Test_InvoiceModelProperties()
        {
            var invoice = new InvoiceModel(1, DateTime.Now, DateTime.Now, null, null,
                                           new PersonModel {
                FirstName = "Dummy", LastName = "Dieter"
            },
                                           new ObservableCollection <InvoiceItemModel>(new[]
            {
                new InvoiceItemModel(1, "Artikel #1", 10, 10.0m, 0.2m),
                new InvoiceItemModel(2, "Artikel #2", 8, 5.0m, 0.1m)
            })
                                           );

            var vm = new InvoiceModelViewModel(invoice);

            vm.PropertyChanged += ((s, e) =>
            {
                if (e.PropertyName == "Message")
                {
                    string message = (s as InvoiceModelViewModel).Message;
                    Assert.AreEqual("Test message", message);
                }
            });

            vm.Message   = "Test message";
            vm.Comment   = "Test comment";
            vm.IssueDate = new DateTime(2014, 9, 10);
            vm.DueDate   = new DateTime(2014, 10, 10);

            Assert.AreEqual(1, vm.ID);
            Assert.AreEqual(2, vm.InvoiceItems.Count);
            Assert.AreEqual("Test message", vm.Message);
            Assert.AreEqual("Test comment", vm.Comment);
            Assert.AreEqual(new DateTime(2014, 9, 10), vm.IssueDate);
            Assert.AreEqual(new DateTime(2014, 10, 10), vm.DueDate);
            Assert.AreEqual(164.0m, vm.Total);
            Assert.AreEqual("Dummy Dieter", vm.DisplayName);
        }