public void AddCustomerDetailsViewModel_SaveCustomerCommandCanNotExecute_WhenRatingIsNotNumeric()
        {
            var viewModel = new AddCustomerDetailsViewModel(_customerDataServiceMock.Object, _regionDataServiceMock.Object);
            var customerModel = new CustomerModel() { FirstName = "Test", LastName = "Test", Email = "Test", Rating = "Test", RegionId = 1 };

            Assert.IsFalse(viewModel.SaveCustomerCommand.CanExecute(customerModel));
        }
        public void UpdateCustomerDetailsViewModel_SaveCustomerCommandCanNotExecute_WhenEmailIsNull()
        {
            var viewModel = new UpdateCustomerDetailsViewModel(_customerDataService.Object, _regionDataService.Object, _customer);
            var customerModel = new CustomerModel() { FirstName = "Test", LastName = "Test", Email = "", Rating = "5", RegionId = 1 };

            Assert.IsFalse(viewModel.SaveCustomerCommand.CanExecute(customerModel));
        }
Пример #3
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            string firstName = (string)values[0];
            string lastName = (string)values[1];
            string email = (string)values[2];
            string rating = (string)values[3];
            int? regionId = (int?)values[4];

            var customerModel = new CustomerModel() { FirstName = firstName, LastName = lastName, Email = email,
                Rating = rating, RegionId = regionId.HasValue ? regionId.Value : 0 };
            return customerModel;
        }
        public void AddCustomerDetailsViewModel_SaveCustomerCommandCallsCustomerDataServiceAddCustomer_WhenSuccessfully()
        {
            var viewModel = new AddCustomerDetailsViewModel(_customerDataServiceMock.Object, _regionDataServiceMock.Object);
            var customerModel = new CustomerModel() { FirstName = "Test", LastName = "Test", Email = "Test", Rating = "5", RegionId = 1 };

            viewModel.SaveCustomerCommand.Execute(customerModel);

            _customerDataServiceMock.Verify(repo => repo.AddCustomer(It.IsAny<Customer>()), Times.Once);
        }
 private async void SaveCustomer(CustomerModel param)
 {
     Mapper.Map(param, Customer);
     await _customerDataService.UpdateCustomer(Customer);
     CloseCurrentView();
 }
 private bool IsValid(CustomerModel param)
 {
     if (!string.IsNullOrWhiteSpace(param.FirstName) && !string.IsNullOrWhiteSpace(param.LastName) && 
         !string.IsNullOrWhiteSpace(param.Email) && param.Rating.IsNumeric())
         return true;
     return false;
 }