public void TestTotalSelectedSales()
        {
            var repos = new CustomerRepository(new FakeCustomerModule());
            var target = new AllCustomersViewModel(repos);

            int notifications = 0;
            target.PropertyChanged += (sender, e) =>
                                          {
                                              if (e.PropertyName == "TotalSelectedSales")
                                                  ++notifications;
                                          };

            Assert.AreEqual(0.0, target.TotalSelectedSales, "Should be zero when no customers are selected");

            CustomerViewModel firstCust = target.AllCustomers[0];

            firstCust.IsSelected = true;
            Assert.AreEqual(1, notifications, "TotalSelectedSales change notification was not raised");
            Assert.AreEqual(firstCust.TotalSales, target.TotalSelectedSales);

            CustomerViewModel secondCust = target.AllCustomers[1];
            secondCust.IsSelected = true;
            Assert.AreEqual(2, notifications, "TotalSelectedSales change notification was not raised again");
            Assert.AreEqual(firstCust.TotalSales + secondCust.TotalSales, target.TotalSelectedSales);
        }
        public void TestNewCustomerIsAdded()
        {
            var repos = new CustomerRepository(new FakeCustomerModule());
            var target = new AllCustomersViewModel(repos);

            Assert.AreEqual(3, target.AllCustomers.Count, "Test data includes three customers");

            repos.AddCustomer(Customer.CreateCustomer(123.45, "new", "customer", false, "*****@*****.**"));

            Assert.AreEqual(4, target.AllCustomers.Count, "Adding a customer to the repository increase the Count");
        }
        public void TestNewCustomerIsAdded()
        {
            CustomerRepository repos = new CustomerRepository(Constants.CUSTOMER_DATA_FILE);
            AllCustomersViewModel target = new AllCustomersViewModel(repos);

            Assert.AreEqual(3, target.AllCustomers.Count, "Test data includes three customers");

            repos.AddCustomer(Customer.CreateCustomer(123.45, "new", "customer", false, "*****@*****.**"));

            Assert.AreEqual(4, target.AllCustomers.Count, "Adding a customer to the repository increase the Count");
        }
        private void ShowAllCustomers()
        {
            var workspace =
                _workspaces.FirstOrDefault(vm => vm is AllCustomersViewModel)
                as AllCustomersViewModel;

            if (workspace == null)
            {
                workspace = new AllCustomersViewModel(_customerRepository);
                _workspaces.Add(workspace);
            }

            _workspaces.SetActiveWorkspace(workspace);
        }
Beispiel #5
0
        void ShowAllCustomers()
        {
            AllCustomersViewModel workspace =
                this.Workspaces.FirstOrDefault(vm => vm is AllCustomersViewModel)
                as AllCustomersViewModel;

            if (workspace == null)
            {
                workspace = new AllCustomersViewModel(_customerRepository);
                this.Workspaces.Add(workspace);
            }

            this.SetActiveWorkspace(workspace);
        }
        void ShowAllCustomers()
        {
            AllCustomersViewModel workspace =
                this.Workspaces.FirstOrDefault(vm => vm is AllCustomersViewModel)
                as AllCustomersViewModel;

            if (workspace == null)
            {
                workspace = new AllCustomersViewModel(_customerRepository);
                this.Workspaces.Add(workspace);
            }

            this.SetActiveWorkspace(workspace);
        }