예제 #1
0
        public void Init()
        {
            this.customers.Clear();
            CustomerInfo[] customerInfos = this.service.GetCustomers();
            this.customers.ReplaceAllItemsWith(customerInfos);

            this.selectedCustomer = this.customers.FirstOrDefault();
        }
        public void Convert_CombinesZipCodeAndCity()
        {
            // Arrange
            var converter = new CustomerToCityStringConverter();
            var customerInfo = new CustomerInfo() { City = "Zürich", Id = 1, Name = "Customer, First", Street = "Bahnhofstrasse 1", ZipCode = "8000" };

            // Act
            string combined = converter.Convert(customerInfo, null, null, CultureInfo.CurrentCulture).ToString();

            // Assert
            Assert.AreEqual("8000 Zürich", combined);
        }
예제 #3
0
        public void SetCustomer(CustomerInfo customer)
        {
            if (customer == null) throw new ArgumentNullException("customer");

            var customerEnity = new Customer
                                    {
                                        Id = customer.Id,
                                        Name = customer.Name,
                                        Street = customer.Street,
                                        City = customer.City,
                                        ZipCode = customer.ZipCode
                                    };

            this.repository.SetCustomer(customerEnity);
        }
예제 #4
0
        public void SetCustomers(CustomerInfo[] customers)
        {
            if (customers == null) throw new ArgumentNullException("customers");

            var customersEntities = customers.Select((ci) =>
            new Customer
            {
                Id = ci.Id,
                Name = ci.Name,
                Street = ci.Street,
                City = ci.City,
                ZipCode = ci.ZipCode
            });

            this.repository.SetCustomerBatch(customersEntities);
        }
예제 #5
0
        public ActionResult New(CustomerViewModel model, string submit)
        {
            model.Id = GetUniqueId();

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            if (String.Equals(submit, "Save", StringComparison.InvariantCultureIgnoreCase))
            {
                var customer = new CustomerInfo
                                   {
                                       Id = model.Id,
                                       Name = model.Name,
                                       City = model.City,
                                   };

                this.customerService.SetCustomer(customer);
            }

            return RedirectToAction("Index", "Customer");
        }
예제 #6
0
        public void SetCustomer_RequestNotExistingCustomer_SetsCustomerInRepository()
        {
            // arrange
            Mock<IRepository> mockedRepository = CreateMockedRepository();
            var service = new CustomerService(mockedRepository.Object);

            const int customerId = 23;
            var customerInfo = new CustomerInfo
            {
                Id = customerId
            };

            // act
            service.SetCustomer(customerInfo);

            // assert
            mockedRepository.Verify(p => p.SetCustomer(It.Is<Customer>(c => c.Id == customerId)));
        }
        public void Init()
        {
            this.beginOfWorkPeriod = this.endOfWorkPeriod = DateTime.Now;

            CustomerInfo[] customerInfos = this.customerService.GetCustomers();
            this.customers.Clear();
            this.customers.AddRange(customerInfos);
            this.selectedCustomer = this.customers.FirstOrDefault();
        }