コード例 #1
0
        public void ShouldLoadAllCustomers_WhenCreated()
        {
            var mock = new Mock<ICustomerService>();
            var customers = new[] {new Customer()};
            mock.Setup(m => m.GetAllCustomers()).Returns(customers);

            var model = new AllCustomersViewModel(mock.Object);

            Assert.AreEqual(customers[0], model.Customers[0].Customer);
        }
コード例 #2
0
        public void ExecuteSelectCustomerCommand_ShouldRaiseCustomerSelectedEvent()
        {
            var model = new AllCustomersViewModel();
            bool raised = false;
            model.CustomerSelected += delegate { raised = true; };

            model.SelectCustomerCommand.Execute(new CustomerViewModel());

            Assert.IsTrue(raised);
        }
コード例 #3
0
        public void CustomerSelectedEvent_ShouldHaveSelectedCustomerInEventArgs()
        {
            var model = new AllCustomersViewModel();
            Customer selectedCustomer = null;
            model.CustomerSelected += (sender, args) => selectedCustomer = args.Item;

            var customerViewModel = new CustomerViewModel(new Customer());
            model.SelectCustomerCommand.Execute(customerViewModel);

            Assert.AreEqual(customerViewModel.Customer, selectedCustomer);
        }
コード例 #4
0
 public void HasSelectCustomerCommand()
 {
     var model = new AllCustomersViewModel();
     Assert.IsNotNull(model.SelectCustomerCommand);
 }
コード例 #5
0
        public void DisplayNameShouldBeAllCustomers()
        {
            var model = new AllCustomersViewModel();

            Assert.AreEqual("All Customers", model.DisplayName);
        }