public void UpdateCustomer_NotDirty_ReturnsFalse()
        {
            // Arrange
            IUiDataProvider uiDataProviderMock = MockRepository.GenerateMock <IUiDataProvider>();
            Customer        expectedCustomer   = new Customer();

            uiDataProviderMock.Stub(u => u.GetCustomer(Arg <string> .Is.Anything)).Return(expectedCustomer);
            CustomerDetailsViewModel viewModel = new CustomerDetailsViewModel(uiDataProviderMock, string.Empty);
            RelayCommand             target    = viewModel.UpdateCommand;

            // act
            bool actual = target.CanExecute(null);

            // assert
            Assert.IsFalse(actual);
        }
        public void UpdateCustomer_Always_CallsUpdateWithCustomer()
        {
            // Arrange
            IUiDataProvider uiDataProviderMock = MockRepository.GenerateMock <IUiDataProvider>();
            Customer        expectedCustomer   = new Customer();

            uiDataProviderMock.Stub(u => u.GetCustomer(Arg <string> .Is.Anything)).Return(expectedCustomer);
            CustomerDetailsViewModel viewModel = new CustomerDetailsViewModel(uiDataProviderMock, string.Empty);
            RelayCommand             target    = viewModel.UpdateCommand;

            // act
            target.Execute(null);

            // assert
            uiDataProviderMock.AssertWasCalled(u => u.Update(expectedCustomer));
        }
        private MainWindowViewModel GetShowCustomerDetails(Customer customer)
        {
            IUiDataProvider uiDataProviderMock = MockRepository.GenerateMock <IUiDataProvider>();
            IToolManager    toolManager        = MockRepository.GenerateMock <IToolManager>();

            uiDataProviderMock.Stub(c => c.GetCustomer(customer.CustomerId)).Return(customer);
            toolManager.Stub(c => c.Tools).Return(new ObservableCollection <ToolViewModel>
            {
                new CustomerDetailsViewModel(uiDataProviderMock, customer.CustomerId, toolManager)
            });

            MainWindowViewModel target = new MainWindowViewModel(uiDataProviderMock, toolManager)
            {
                SelectedCustomerId = customer.CustomerId
            };

            return(target);
        }
        public void Customer_Always_ReturnsCustomerFromGetCustomer()
        {
            // Arrange
            IUiDataProvider uiDataProviderMock = MockRepository.GenerateMock <IUiDataProvider>();
            const string    expectedId         = "EXPECTEDID";
            Customer        expectedCustomer   = new Customer
            {
                CustomerId = expectedId
            };

            uiDataProviderMock.Stub(c => c.GetCustomer(expectedId)).Return(expectedCustomer);

            // Act
            CustomerDetailsViewModel target = new CustomerDetailsViewModel(uiDataProviderMock, expectedId);

            // Assert
            Assert.AreSame(expectedCustomer, target.Customer);
        }
        public void DisplayName_Always_ReturnsCompanyName()
        {
            // Arrange
            IUiDataProvider uiDataProviderMock  = MockRepository.GenerateMock <IUiDataProvider>();
            const string    expectedId          = "EXPECTEDID";
            const string    expectedCompanyName = "EXPECTEDNAME";

            Customer expectedCustomer = new Customer
            {
                CustomerId  = expectedId,
                CompanyName = expectedCompanyName,
            };

            uiDataProviderMock.Stub(c => c.GetCustomer(expectedId)).Return(expectedCustomer);

            // Act
            CustomerDetailsViewModel target = new CustomerDetailsViewModel(uiDataProviderMock, expectedId);

            // Assert
            Assert.AreSame(expectedCompanyName, target.DisplayName);
        }