Exemplo n.º 1
0
        public void UpdateCustomer()
        {
            try
            {
                CustomerController cCtrl  = new CustomerController();
                ZipCityController  zcCtrl = new ZipCityController();

                ZipCity zipCity = zcCtrl.ReadByZipCode("9000");

                Customer newCustomer = new Customer
                {
                    _fName   = "Lars",
                    _lName   = "Jensen",
                    _email   = "*****@*****.**",
                    _address = "broen 20",
                    _phone   = "55667788",
                    _zipCity = zipCity
                };
                cCtrl.Update(newCustomer, "55667788");
                Customer commitedCustomer = cCtrl.ReadByPhone("55667788");
                Assert.IsTrue(newCustomer._fName == commitedCustomer._fName);
            }
            catch (FaultException <CustomerNotExistException> cEx)
            {
                Console.WriteLine(cEx.Message);
            }
        }
Exemplo n.º 2
0
        public void AddCustomerToOrder()
        {
            // arrange
            OrderController    oCtrl = new OrderController();
            CustomerController cCtrl = new CustomerController();
            ZipCityController  zCtrl = new ZipCityController();

            Customer customer = new Customer
            {
                _address = "Ibsvej 1",
                _email   = "*****@*****.**",
                _fName   = "Ib",
                _lName   = "Ibsen",
                _phone   = "24440744",
                _zipCity = zCtrl.ReadByZipCode("9000")
            };

            // act
            int orderId    = oCtrl.CreateOrder();
            int customerId = cCtrl.Create(customer);

            oCtrl.AddCustomer(orderId, customerId);
            Order newOrder = oCtrl.ReadOrder(orderId);

            // assert
            Assert.IsTrue(newOrder._customer._id == customerId);
        }
Exemplo n.º 3
0
        public void CheckZipcodeIsIllegal()
        {
            ZipCityController zcCtrl = new ZipCityController();

            try
            {
                ZipCity zipCity = zcCtrl.ReadByZipCode("34512");
                Assert.IsTrue(zipCity._zipCode == 3451);
            }
            catch (FaultException <ZipCodeLengthException> zipEx)
            {
                Console.WriteLine(zipEx.Message);
            }
        }
Exemplo n.º 4
0
        public void CreateCustomer()
        {
            CustomerController cCtrl  = new CustomerController();
            ZipCityController  zcCtrl = new ZipCityController();

            Customer customer = new Customer
            {
                _fName   = "Peter",
                _lName   = "Kurtsen",
                _email   = "*****@*****.**",
                _address = "Vejen 30",
                _phone   = "11223344",
                _zipCity = zcCtrl.ReadByZipCode("9700")
            };

            customer._id = cCtrl.Create(customer);

            string email = cCtrl.ReadByPhone(customer._phone)._email;

            Assert.IsTrue(customer._email == email);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new ZipCitycontroller and uses its method getall.
        /// </summary>
        /// <returns>IEnumerable<ZipCity> ListOfzipcities</returns>
        public IEnumerable <ZipCity> GetAll()
        {
            ZipCityController zipCityController = new ZipCityController();

            return(zipCityController.GetAll());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new ZipCitycontroller and uses its method readByZipCode with the given parameters.
        /// </summary>
        /// <param name="zipCode"></param>
        /// <returns>Zipcity zipcity</returns>
        public ZipCity ReadByZipCode(string zipCode)
        {
            ZipCityController zipCityController = new ZipCityController();

            return(zipCityController.ReadByZipCode(zipCode));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new ZipCitycontroller and uses its method read with the given parameters.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Zipcity zipcity</returns>
        public ZipCity Read(int id)
        {
            ZipCityController zipCityController = new ZipCityController();

            return(zipCityController.Read(id));
        }