Example #1
0
    public void Run()
    {
        var memberMappings = MappingFinder.GetMappings(DefinitionFinder.FindType <ClassWithAutoPropertiesAndDodgyField>()).ToList();

        Assert.AreEqual("<Property1>k__BackingField", memberMappings.First(x => x.PropertyDefinition.Name == "Property1").FieldDefinition.Name);
        Assert.AreEqual("<Property2>k__BackingField", memberMappings.First(x => x.PropertyDefinition.Name == "Property2").FieldDefinition.Name);
    }
    public void WithLowerUnderScoreBackingFields()
    {
        var memberMappings = MappingFinder.GetMappings(DefinitionFinder.FindType <ClassWithUnderScoreBackingFields>()).ToList();

        Assert.AreEqual("_property1", memberMappings.First(x => x.PropertyDefinition.Name == "Property1").FieldDefinition.Name);
        Assert.AreEqual("_property2", memberMappings.First(x => x.PropertyDefinition.Name == "Property2").FieldDefinition.Name);
    }
    public void Run()
    {
        var memberMappings = MappingFinder.GetMappings(DefinitionFinder.FindType <ClassWithSingleBackingFieldsSet>()).ToList();

        Assert.AreEqual("propertya", memberMappings.First(x => x.PropertyDefinition.Name == "Property1").FieldDefinition.Name);
        Assert.AreEqual("propertyb", memberMappings.First(x => x.PropertyDefinition.Name == "Property2").FieldDefinition.Name);
    }
Example #4
0
    public void Run()
    {
        var typeDefinition = DefinitionFinder.FindType <Person>();
        var node           = new TypeNode
        {
            TypeDefinition = typeDefinition,
            Mappings       = MappingFinder.GetMappings(typeDefinition).ToList()
        };

        new IlGeneratedByDependencyReader(node).Process();
        Assert.AreEqual(0, node.PropertyDependencies.Count);
    }
    public void Run()
    {
        var typeDefinition = DefinitionFinder.FindType <TestClass>();
        var node           = new TypeNode
        {
            TypeDefinition = typeDefinition,
            Mappings       = MappingFinder.GetMappings(typeDefinition).ToList()
        };

        new IlGeneratedByDependencyReader(node).Process();
        Assert.AreEqual(1, node.PropertyDependencies.Count);
        Assert.AreEqual("PropertyWithLambda", node.PropertyDependencies[0].ShouldAlsoNotifyFor.Name);
        Assert.AreEqual("Property1", node.PropertyDependencies[0].WhenPropertyIsSet.Name);
    }
Example #6
0
    public void Run()
    {
        var typeDefinition = DefinitionFinder.FindType <Person <int> >();
        var node           = new TypeNode
        {
            TypeDefinition = typeDefinition,
            Mappings       = MappingFinder.GetMappings(typeDefinition).ToList()
        };

        new IlGeneratedByDependencyReader(node).Process();
        Assert.AreEqual("FullName", node.PropertyDependencies[0].ShouldAlsoNotifyFor.Name);
        Assert.AreEqual("GivenNames", node.PropertyDependencies[0].WhenPropertyIsSet.Name);
        Assert.AreEqual("FullName", node.PropertyDependencies[1].ShouldAlsoNotifyFor.Name);
        Assert.AreEqual("FamilyName", node.PropertyDependencies[1].WhenPropertyIsSet.Name);
    }
    public void Run()
    {
        var memberMappings = MappingFinder.GetMappings(DefinitionFinder.FindType <Model>()).ToList();

        Assert.IsNull(memberMappings.First().FieldDefinition);
    }