mardi 3 mars 2015

AutoPoco does't work

I have an object like this:



public class TenderEntryModel : ITenderEntry
{
public int ID { get; set; }
public string Description { get; set; }
public decimal Amount { get; set; }
}


And I config AutoPoco like this:



[TestMethod]
public void Insert()
{
IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
{
x.Conventions(c =>
{
c.UseDefaultConventions();
});

x.AddFromAssemblyContainingType<TenderEntryModel>();
});
IGenerationSession session = factory.CreateSession();
TenderEntryModel tenderEntryModel = session.Single<TenderEntryModel>().Get();
TenderEntryModel tenderEntryModel1 = new TenderEntryModel();

// UNDONE:
TenderEntryModelFactory.CreateTenderEntry(tenderEntryModel);
}


But what I get when debugging is tenderEntryModel is exactly same with tenderEntryModel1, AutoPoco doesn't help to populate any mockup value for me. What did I do wrong? I also try to write some convention for ID and string, like this



class StringPropertyConvention : ITypePropertyConvention
{
public void Apply(ITypePropertyConventionContext context)
{
context.SetSource<LoremIpsumSource>();
}

public void SpecifyRequirements(ITypeMemberConventionRequirements requirements)
{
requirements.Type(x => x == typeof(String));
}
}

public class IDPropertyConvention : ITypePropertyConvention
{
public void Apply(ITypePropertyConventionContext context)
{
context.SetSource<IntegerIdSource>();
}

public void SpecifyRequirements(ITypeMemberConventionRequirements requirements)
{
requirements.Name(x => x.Equals("ID"));
requirements.Type(x => x == typeof(int));
}
}


and config like this:



IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
{
x.Conventions(c =>
{
//c.UseDefaultConventions();
c.Register(typeof(IDPropertyConvention));
c.Register(typeof(StringPropertyConvention));
});

x.AddFromAssemblyContainingType<TenderEntryModel>();
});


But it still doesn't popular and mockup value for TenderEntryModel. Please help me. Thanks.


Aucun commentaire:

Enregistrer un commentaire