Beispiel #1
0
        public void TestRemoveNonexistingCustomer()
        {
            var customerManagerMock      = new Mock <ICustomerManager>();
            var minorCustomerManagerMock = new Mock <IMinorCustomerManager>();

            customerManagerMock.Setup(m =>
                                      m.GetCustomerByCustomerID(It.IsAny <int>()))
            .Returns((Customer)null);

            var customerAndMinorCustomerAPI = new CustomerAndMinorCustomerAPI(customerManagerMock.Object, minorCustomerManagerMock.Object, null);
            var successfull = customerAndMinorCustomerAPI.RemoveCustomer(1);

            Assert.AreEqual(ErrorCodesRemoveCustomer.NoSuchCustomer, successfull);
            customerManagerMock.Verify(m =>
                                       m.RemoveCustomer(It.IsAny <int>()), Times.Never);
        }
Beispiel #2
0
        public void TestRemoveExistingCustomer()
        {
            var customerManagerMock      = new Mock <ICustomerManager>();
            var minorCustomerManagerMock = new Mock <IMinorCustomerManager>();

            customerManagerMock.Setup(m =>
                                      m.GetCustomerByCustomerID(It.IsAny <int>()))
            .Returns(new Customer
            {
                CustomerID     = 4,
                MinorCustomers = new List <MinorCustomer>()
            });

            var customerAndMinorCustomerAPI = new CustomerAndMinorCustomerAPI(customerManagerMock.Object, minorCustomerManagerMock.Object, null);
            var successfull = customerAndMinorCustomerAPI.RemoveCustomer(4);

            Assert.AreEqual(ErrorCodesRemoveCustomer.Ok, successfull);
            customerManagerMock.Verify(m =>
                                       m.RemoveCustomer(It.IsAny <int>()), Times.Once);
        }
Beispiel #3
0
        public void TestRemoveCustomerWithMinorCustomer()
        {
            var customerManagerMock      = new Mock <ICustomerManager>();
            var minorCustomerManagerMock = new Mock <IMinorCustomerManager>();

            customerManagerMock.Setup(m =>
                                      m.GetCustomerByCustomerID(It.IsAny <int>()))
            .Returns(new Customer
            {
                CustomerID     = 1,
                MinorCustomers = new List <MinorCustomer>
                {
                    new MinorCustomer()
                }
            });


            var customerAndMinorCustomerAPI = new CustomerAndMinorCustomerAPI(customerManagerMock.Object, minorCustomerManagerMock.Object, null);
            var successfull = customerAndMinorCustomerAPI.RemoveCustomer(1);

            Assert.AreEqual(ErrorCodesRemoveCustomer.CustomerIsConnectedToMinorCustomer, successfull);
            customerManagerMock.Verify(m =>
                                       m.RemoveCustomer(It.IsAny <int>()), Times.Never);
        }