Exemplo n.º 1
0
 private void AssertCanNotSet(PropertyInfoAdapter adapter, object instance, SimpleReferenceType value)
 {
     try
     {
         adapter.SetValue(instance, value, null);
     }
     catch (ArgumentException ex)
     {
         Assert.That(ex.Message, Is.EqualTo("Property set method not found."));
     }
 }
Exemplo n.º 2
0
        public void SetValue_WithIndexerProperty_WithOneParameter_IndexParameterArrayLengthMismatch()
        {
            var scalar       = new SimpleReferenceType();
            var instanceStub = MockRepository.GenerateStub <IInterfaceWithReferenceType <SimpleReferenceType> >();

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

            _implicitInterfaceAdapter = PropertyInfoAdapter.Create(interfaceDeclarationProperty);

            _implicitInterfaceAdapter.SetValue(instanceStub, scalar, new object[0]);
        }
Exemplo n.º 3
0
        public void SetValue_WithIndexerProperty_WithTwoParameters_IndexParameterArrayNull()
        {
            var scalar       = new SimpleReferenceType();
            var instanceStub = MockRepository.GenerateStub <IInterfaceWithReferenceType <SimpleReferenceType> >();

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

            _implicitInterfaceAdapter = PropertyInfoAdapter.Create(interfaceDeclarationProperty);

            _implicitInterfaceAdapter.SetValue(instanceStub, scalar, null);
        }
Exemplo n.º 4
0
        public void SetValue_WithIndexerProperty_WithOneParameter()
        {
            var scalar       = new SimpleReferenceType();
            var instanceMock = MockRepository.GenerateMock <IInterfaceWithReferenceType <SimpleReferenceType> >();

            instanceMock.Expect(mock => mock[10] = scalar);
            instanceMock.Replay();

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

            _implicitInterfaceAdapter = PropertyInfoAdapter.Create(interfaceDeclarationProperty);

            _implicitInterfaceAdapter.SetValue(instanceMock, scalar, new object[] { 10 });
            instanceMock.VerifyAllExpectations();
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
 private void AssertCanSet(PropertyInfoAdapter adapter, object instance, SimpleReferenceType value)
 {
     adapter.SetValue(instance, value, null);
     Assert.That(adapter.GetValue(instance, null), Is.SameAs(value));
 }