public void CreateRequiredMethodDefinitions_BaseWithSameMembers()
        {
            var targetClassDefinition = DefinitionObjectMother.CreateTargetClassDefinition(typeof(ClassImplementingInterfaceWithDuckTypingWithBaseWithSameMembers));

            DefinitionObjectMother.CreateMethodDefinition(
                targetClassDefinition,
                typeof(ClassImplementingInterfaceWithDuckTyping).GetMethod("Method1"));
            DefinitionObjectMother.CreateMethodDefinition(
                targetClassDefinition,
                typeof(ClassImplementingInterfaceWithDuckTyping).GetMethod("Method2"));
            var m1b = DefinitionObjectMother.CreateMethodDefinition(
                targetClassDefinition,
                typeof(ClassImplementingInterfaceWithDuckTypingWithBaseWithSameMembers).GetMethod("Method1"));
            var m2b = DefinitionObjectMother.CreateMethodDefinition(
                targetClassDefinition,
                typeof(ClassImplementingInterfaceWithDuckTypingWithBaseWithSameMembers).GetMethod("Method2"));

            var requirement = DefinitionObjectMother.CreateRequiredTargetCallTypeDefinition(targetClassDefinition, typeof(IInterface));
            var builder     = new DuckTypingRequiredMethodDefinitionCollector(targetClassDefinition);

            var definitions = builder.CreateRequiredMethodDefinitions(requirement).OrderBy(def => def.FullName).ToArray();

            Assert.That(definitions.Length, Is.EqualTo(2));

            Assert.That(definitions[0].DeclaringRequirement, Is.SameAs(requirement));
            Assert.That(definitions[0].InterfaceMethod, Is.EqualTo(typeof(IInterface).GetMethod("Method1")));
            Assert.That(definitions[0].ImplementingMethod, Is.SameAs(m1b));

            Assert.That(definitions[1].DeclaringRequirement, Is.SameAs(requirement));
            Assert.That(definitions[1].InterfaceMethod, Is.EqualTo(typeof(IInterface).GetMethod("Method2")));
            Assert.That(definitions[1].ImplementingMethod, Is.SameAs(m2b));
        }
        public void CreateRequiredMethodDefinitions_NoMatch_NoRequiringMixin()
        {
            var targetClassDefinition = DefinitionObjectMother.CreateTargetClassDefinition(typeof(object));

            var requirement = DefinitionObjectMother.CreateRequiredTargetCallTypeDefinition(targetClassDefinition, typeof(IInterface));
            var builder     = new DuckTypingRequiredMethodDefinitionCollector(targetClassDefinition);

            builder.CreateRequiredMethodDefinitions(requirement).ToArray();
        }
        public void CreateRequiredMethodDefinitions_NoMatch()
        {
            var targetClassDefinition = DefinitionObjectMother.CreateTargetClassDefinition(typeof(object));
            var requiringMixin        = DefinitionObjectMother.CreateMixinDefinition(targetClassDefinition, typeof(string));

            var dependency  = DefinitionObjectMother.CreateTargetCallDependencyDefinition(requiringMixin);
            var requirement = dependency.RequiredType;

            DefinitionObjectMother.AddRequiringDependency(requirement, dependency);

            var builder = new DuckTypingRequiredMethodDefinitionCollector(targetClassDefinition);

            builder.CreateRequiredMethodDefinitions(requirement).ToArray();
        }
        public void CreateRequiredMethodDefinitions_WithOverloads()
        {
            var targetClassDefinition = DefinitionObjectMother.CreateTargetClassDefinition(typeof(ClassImplementingInterfaceWithDuckTypingWithOverloads));

            DefinitionObjectMother.CreateMethodDefinition(
                targetClassDefinition,
                typeof(ClassImplementingInterfaceWithDuckTypingWithOverloads).GetMethod("Method1", new[] { typeof(string) }));
            var m1b = DefinitionObjectMother.CreateMethodDefinition(
                targetClassDefinition,
                typeof(ClassImplementingInterfaceWithDuckTypingWithOverloads).GetMethod("Method1", Type.EmptyTypes));

            DefinitionObjectMother.CreateMethodDefinition(
                targetClassDefinition,
                typeof(ClassImplementingInterfaceWithDuckTypingWithOverloads).GetMethod("Method2"));

            var requirement = DefinitionObjectMother.CreateRequiredTargetCallTypeDefinition(targetClassDefinition, typeof(IInterface));
            var builder     = new DuckTypingRequiredMethodDefinitionCollector(targetClassDefinition);

            var definitions = builder.CreateRequiredMethodDefinitions(requirement).OrderBy(def => def.FullName).ToArray();

            Assert.That(definitions[0].DeclaringRequirement, Is.SameAs(requirement));
            Assert.That(definitions[0].InterfaceMethod, Is.EqualTo(typeof(IInterface).GetMethod("Method1")));
            Assert.That(definitions[0].ImplementingMethod, Is.SameAs(m1b));
        }