コード例 #1
0
        public void SetValue_WithIndexerProperty_WithThreeParameters()
        {
            SimpleReferenceType scalar = new SimpleReferenceType();
            IInterfaceWithReferenceType <SimpleReferenceType> instanceMock = MockRepository.GenerateMock <IInterfaceWithReferenceType <SimpleReferenceType> >();

            instanceMock.Expect(mock => mock[10, new DateTime(2000, 1, 1), "foo"] = scalar);
            instanceMock.Replay();

            var interfaceDeclarationProperty = typeof(IInterfaceWithReferenceType <SimpleReferenceType>)
                                               .GetProperty("Item", new[] { typeof(int), typeof(DateTime), typeof(string) });

            _implicitInterfaceAdapter = PropertyInfoAdapter.Create(interfaceDeclarationProperty);

            _implicitInterfaceAdapter.SetValue(instanceMock, scalar, new object[] { 10, new DateTime(2000, 1, 1), "foo" });
            instanceMock.VerifyAllExpectations();
        }
コード例 #2
0
        public void GetValue_WithIndexerProperty_TwoParameters()
        {
            SimpleReferenceType scalar = new SimpleReferenceType();
            IInterfaceWithReferenceType <SimpleReferenceType> instanceMock = MockRepository.GenerateMock <IInterfaceWithReferenceType <SimpleReferenceType> >();

            instanceMock.Expect(mock => mock[10, new DateTime(2000, 1, 1)]).Return(scalar);
            instanceMock.Replay();

            var interfaceDeclarationProperty = typeof(IInterfaceWithReferenceType <SimpleReferenceType>)
                                               .GetProperty("Item", new[] { typeof(int), typeof(DateTime) });

            _implicitInterfaceAdapter = PropertyInfoAdapter.Create(interfaceDeclarationProperty);

            object actualScalar = _implicitInterfaceAdapter.GetValue(instanceMock, new object[] { 10, new DateTime(2000, 1, 1) });

            Assert.That(actualScalar, Is.SameAs(scalar));
            instanceMock.VerifyAllExpectations();
        }