예제 #1
0
        public void GetCustomer_Always_CallsGetCustomer()
        {
            // arrange
            const string     expectedId          = "expectedId";
            ICustomerService customerServiceStub = MockRepository.GenerateMock <ICustomerService>();

            CustomerTranslator.Instance = MockRepository.GenerateStub <IEntityTranslator <Model.Customer, Service.Customer> >();
            UiDataProvider target = new UiDataProvider(customerServiceStub);
            var            dto    = new Service.Customer()
            {
                CustomerId = expectedId
            };
            var model = new Model.Customer()
            {
                CustomerId = expectedId
            };
            var customerDtos = new Service.Customer[] { dto };

            customerServiceStub.Stub(c => c.GetCustomers()).Return(customerDtos);
            CustomerTranslator.Instance.Stub(c => c.CreateModel(dto)).Return(model);
            target.GetCustomers();

            // act
            target.GetCustomer(expectedId);

            // assert
            customerServiceStub.AssertWasCalled(c => c.GetCustomer(expectedId));
        }
예제 #2
0
        public void GetCustomer_Always_CallsGetCustomer()
        {
            const string expectedID = "expectedID";

            ICustomerService customerServiceMock = MockRepository.GenerateMock <ICustomerService>();

            CustomerTranslator.Instance = MockRepository.GenerateStub <IEntityTranslator <Model.Customer, Customer> >();
            UiDataProvider target = new UiDataProvider(customerServiceMock);

            var dto = new Customer {
                CustomerID = expectedID
            };
            var model = new Model.Customer {
                CustomerId = expectedID
            };
            var customerDtos = new[] { dto };

            customerServiceMock.Stub(c => c.GetCustomers()).Return(customerDtos);
            CustomerTranslator.Instance.Stub(c => c.CreateModel(dto)).Return(model);
            target.GetCustomers();
            target.GetCustomer(expectedID);

            customerServiceMock.AssertWasCalled(c => c.GetCustomer(expectedID));
        }