Esempio n. 1
0
        public void UpdateCustomer_CorrectResult_StatusTrue()
        {
            #region Preperation

            var customer = ServiceInstance.AddCustomer(new Customer
            {
                FirstName = "Test FirstName",
                LastName  = "Test LastName"
            });

            #endregion

            var expextedResult = new CustomerServiceResponse
            {
                Status  = true,
                Message = "Customer updated"
            };

            var actualResult = ServiceInstance.UpdateCustomer(new Customer
            {
                Id        = customer.Customer.Id,
                FirstName = "Test FirstName 2",
                LastName  = "Test LastName 2"
            });

            Assert.AreEqual(expextedResult.Status, actualResult.Status);
            Assert.AreEqual(expextedResult.Message, actualResult.Message);
            Assert.AreEqual(customer.Customer.FirstName, actualResult.Customer.FirstName);
            Assert.AreEqual(customer.Customer.LastName, actualResult.Customer.LastName);
        }
Esempio n. 2
0
        public void UpdateCustomer_EmptyLastName_StatusFalse()
        {
            #region Preperation

            var customer = ServiceInstance.AddCustomer(new Customer
            {
                FirstName = "Test FirstName",
                LastName  = "Test LastName"
            });

            #endregion

            var expextedResult = new CustomerServiceResponse
            {
                Status  = false,
                Message = "FirstName or LastName cannot be null or empty"
            };

            var actualResult = ServiceInstance.UpdateCustomer(new Customer
            {
                Id        = customer.Customer.Id,
                FirstName = "Test",
                LastName  = string.Empty
            });

            Assert.AreEqual(expextedResult.Status, actualResult.Status);
            Assert.AreEqual(expextedResult.Message, actualResult.Message);
        }
Esempio n. 3
0
        public void DeleteCustomer_CorrectResult_StatusTrue()
        {
            #region Preperation

            var customer = ServiceInstance.AddCustomer(new Customer
            {
                FirstName = "Test FirstName",
                LastName  = "Test LastName"
            });

            // Dummy Mock Method Setup
            _dummyServiceAnother.Setup(x => x.DummyAnother(5))
            .Returns(true);

            #endregion

            var expextedResult = new CustomerServiceResponse
            {
                Status  = true,
                Message = "Customer deleted"
            };

            var actualResult = ServiceInstance.DeleteCustomer(customer.Customer.Id);

            Assert.AreEqual(expextedResult.Status, actualResult.Status);
            Assert.AreEqual(expextedResult.Message, actualResult.Message);
        }
Esempio n. 4
0
        public void AddCustomer_NullEntity_StatusFalse()
        {
            var expextedResult = new CustomerServiceResponse
            {
                Status  = false,
                Message = "Customer entity cannot be null"
            };

            var actualResult = ServiceInstance.AddCustomer(null);

            Assert.AreEqual(expextedResult.Status, actualResult.Status);
            Assert.AreEqual(expextedResult.Message, actualResult.Message);
        }
Esempio n. 5
0
        public void AddCustomer_NullLastName_StatusFalse()
        {
            var expextedResult = new CustomerServiceResponse
            {
                Status  = false,
                Message = "FirstName or LastName cannot be null or empty"
            };

            var actualResult = ServiceInstance.AddCustomer(new Customer
            {
                FirstName = "Test",
                LastName  = null
            });

            Assert.AreEqual(expextedResult.Status, actualResult.Status);
            Assert.AreEqual(expextedResult.Message, actualResult.Message);
        }
Esempio n. 6
0
        public void AddCustomer_CorrectResult_StatusTrue()
        {
            var expextedResult = new CustomerServiceResponse
            {
                Status  = true,
                Message = "Customer added"
            };

            var actualResult = ServiceInstance.AddCustomer(new Customer
            {
                FirstName = "Test FirstName",
                LastName  = "Test LastName"
            });

            Assert.AreEqual(expextedResult.Status, actualResult.Status);
            Assert.AreEqual(expextedResult.Message, actualResult.Message);
            Assert.IsNotNull(actualResult.Customer);
        }
Esempio n. 7
0
        public void GetCustomer_CorrectResult_StatusTrue()
        {
            #region Preperation

            var customer = ServiceInstance.AddCustomer(new Customer
            {
                FirstName = "Test FirstName",
                LastName  = "Test LastName"
            });

            #endregion

            var expextedResult = new CustomerServiceResponse
            {
                Status = true
            };

            var actualResult = ServiceInstance.GetCustomer(customer.Customer.Id);

            Assert.AreEqual(expextedResult.Status, actualResult.Status);
            Assert.IsNotNull(actualResult.Customer);
        }