コード例 #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
ファイル: UIDataProviderTests.cs プロジェクト: loorens/Visual
        public void GetCustomers_Always_CallsGetCustomers()
        {
            ICustomerService customerServiceMock = MockRepository.GenerateMock <ICustomerService>();

            UiDataProvider target = new UiDataProvider(customerServiceMock);

            var customerDtos = new[] { new Customer() };

            customerServiceMock.Stub(c => c.GetCustomers()).Return(customerDtos);

            target.GetCustomers();

            customerServiceMock.AssertWasCalled(c => c.GetCustomers());
        }
コード例 #3
0
        public void GetCustomers_Always_CallsGetCustomers()
        {
            // arrange
            ICustomerService customerServiceStub = MockRepository.GenerateMock <ICustomerService>();
            UiDataProvider   target = new UiDataProvider(customerServiceStub);
            var customerDtos        = new Service.Customer[] { new Service.Customer() };

            customerServiceStub.Stub(c => c.GetCustomers()).Return(customerDtos);

            // act
            target.GetCustomers();

            // assert
            customerServiceStub.AssertWasCalled(c => c.GetCustomers());
        }
コード例 #4
0
ファイル: UIDataProviderTests.cs プロジェクト: loorens/Visual
        public void GetCustomers_ServiceReturnsDto_DtoPassedToTranslator()
        {
            ICustomerService customerServiceStub = MockRepository.GenerateStub <ICustomerService>();

            CustomerTranslator.Instance = MockRepository.GenerateStub <IEntityTranslator <Model.Customer, Customer> >();

            UiDataProvider target = new UiDataProvider(customerServiceStub);

            var expected      = new Customer();
            var customersDtos = new[] { expected };

            customerServiceStub.Stub(c => c.GetCustomers()).Return(customersDtos);

            target.GetCustomers();

            CustomerTranslator.Instance.AssertWasCalled(c => c.CreateModel(expected));
        }
コード例 #5
0
ファイル: UIDataProviderTests.cs プロジェクト: loorens/Visual
        public void GetCustomers_ServiceReturnsDto_ModelReturnedFromTranslator()
        {
            ICustomerService customerServiceStub = MockRepository.GenerateStub <ICustomerService>();

            CustomerTranslator.Instance = MockRepository.GenerateStub <IEntityTranslator <Model.Customer, Customer> >();

            UiDataProvider target        = new UiDataProvider(customerServiceStub);
            var            dto           = new Customer();
            var            expected      = new Model.Customer();
            var            customersDtos = new[] { dto };

            customerServiceStub.Stub(c => c.GetCustomers()).Return(customersDtos);
            CustomerTranslator.Instance.Stub(c => c.CreateModel(dto)).Return(expected);

            var actual = target.GetCustomers();

            Assert.AreSame(expected, actual[0]);
        }
コード例 #6
0
ファイル: UIDataProviderTests.cs プロジェクト: loorens/Visual
        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));
        }