CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

No Title

90 Views
Copy Code Show/Hide Line Numbers
[Fact]
public void GetParts_should_return_definitions_with_import_member_matching_conventions()
{
    var typeLoader =
        new Mock<ITypeLoader>();
    typeLoader.SetupGet(t => t.Types).Returns(new List<Type> { typeof(FakePart) });
 
    var model =
       new ConventionModel();
 
    model.Conventions.Add(new Convention
    {
        Condition = t => true,
        Imports = new List<IImportConvention>
        {
            new ImportConvention
            {
                Contract = "Foo",
                Member = typeof(FakePart).GetProperty("Name")
            }
        }
    });
 
    var definition =
        model.GetParts(typeLoader.Object).Single().ImportDefinitions.Cast<ContractBasedImportDefinition>().First();
 
    var export =
        ReflectionModelServices.CreateExportDefinition(
            model.Conventions.First().Imports.First().Member.ToLazyMemberInfo(),
            "Foo",
            new Lazy<IDictionary<string, object>>(), null);
 
    var results =
        definition.IsConstraintSatisfiedBy(export);
 
    results.ShouldBeTrue();
}
by TheCodeJunkie
  January 05, 2010 @ 3:55am

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate