Exemplo n.º 1
0
        public void AcceptVisitorTest()
        {
            // Arrange
            var proxyDefinition = new DelegateProxyDefinition(typeof(Action), new[] { typeof(IOne), typeof(ITwo), typeof(IOneTwo) });

            // Act
            var proxyDefinitionVisitor = new CollectingProxyDefinitionVisitor();

            proxyDefinition.AcceptVisitor(proxyDefinitionVisitor);

            // Assert
            Assert.That(proxyDefinition.DeclaringType, Is.EqualTo(typeof(Action)));
            Assert.That(proxyDefinition.ParentType, Is.EqualTo(typeof(object)));
            Assert.That(proxyDefinition.ImplementedInterfaces.Count(), Is.EqualTo(4));
            Assert.That(proxyDefinition.ImplementedInterfaces, Contains.Item(typeof(IBase)));
            Assert.That(proxyDefinition.ImplementedInterfaces, Contains.Item(typeof(IOne)));
            Assert.That(proxyDefinition.ImplementedInterfaces, Contains.Item(typeof(ITwo)));
            Assert.That(proxyDefinition.ImplementedInterfaces, Contains.Item(typeof(IOneTwo)));
            Assert.That(proxyDefinitionVisitor.InterfaceTypes.Count, Is.EqualTo(4));
            Assert.That(proxyDefinitionVisitor.InterfaceTypes, Contains.Item(typeof(IBase)));
            Assert.That(proxyDefinitionVisitor.InterfaceTypes, Contains.Item(typeof(IOne)));
            Assert.That(proxyDefinitionVisitor.InterfaceTypes, Contains.Item(typeof(ITwo)));
            Assert.That(proxyDefinitionVisitor.InterfaceTypes, Contains.Item(typeof(IOneTwo)));

            Assert.That(proxyDefinitionVisitor.ConstructorInfos.Count, Is.EqualTo(1));

            Assert.That(proxyDefinitionVisitor.EventInfos.Count, Is.EqualTo(3));

            Assert.That(proxyDefinitionVisitor.PropertyInfos.Count, Is.EqualTo(6));

            Assert.That(proxyDefinitionVisitor.MethodInfos.Count, Is.EqualTo(8));
        }
Exemplo n.º 2
0
        public void EqualsWithDeclaringInterfaceTest()
        {
            // Arrange
            var firstProxyDefinition  = new DelegateProxyDefinition(typeof(Action), Type.EmptyTypes);
            var secondProxyDefinition = new DelegateProxyDefinition(typeof(Action), new[] { typeof(ICloneable) });

            // Act
            var equals = firstProxyDefinition.Equals(secondProxyDefinition);

            // Assert
            Assert.That(equals, Is.True);
        }
Exemplo n.º 3
0
        public void EqualsWithSwappedInterfacesTest()
        {
            // Arrange
            var firstProxyDefinition  = new DelegateProxyDefinition(typeof(Action), new[] { typeof(IOne), typeof(ITwo) });
            var secondProxyDefinition = new DelegateProxyDefinition(typeof(Action), new[] { typeof(ITwo), typeof(IOne) });

            // Act
            var equals = firstProxyDefinition.Equals(secondProxyDefinition);

            // Assert
            Assert.That(equals, Is.True);
        }
Exemplo n.º 4
0
        public void EqualsWithoutInterfacesTest()
        {
            // Arrange
            var firstProxyDefinition  = new DelegateProxyDefinition(typeof(Action), Type.EmptyTypes);
            var secondProxyDefinition = new DelegateProxyDefinition(typeof(Action), Type.EmptyTypes);

            // Act
            var equals = firstProxyDefinition.Equals(secondProxyDefinition);

            // Assert
            Assert.That(equals, Is.True);
        }