When I resolve reminder in the following code, the properties of contact and profile are not initialized. What am I missing?
public class Reminder : IReminder
{
IProfile profile;
IContact contact;
public Reminder(IProfile profile, IContact contact)
{
this.profile = profile;
this.contact = contact;
}
}
IProfile profile;
IContact contact;
IReminder reminder;
[TestInitialize]
public void TestInit()
{
var container = new UnityContainer();
profile = new Profile() { ID = 1, Active = true };
container.RegisterInstance(profile);
contact = new Contact() { ID = 1, Active = true };
container.RegisterInstance(contact);
container.RegisterType<IContact, Contact>(new ContainerControlledLifetimeManager());
container.RegisterType<IProfile, Profile>(new ContainerControlledLifetimeManager());
reminder = container.Resolve<Reminder>();
// at this point I examine, reminder and expect that contact ID and Active //
//should be 1 and true respectively. But I see that its 0 and false. Same with
// profile. Why? }
Aucun commentaire:
Enregistrer un commentaire