Ejemplo n.º 1
0
    public void DependencyContainer_ResolvesRegisteredType()
    {
        DependencyContainer container = this.GetNewContainer();

        container.Register <IMockInterfaceObject, MockObject>();

        IMockInterfaceObject resolvedObject = container.Resolve <IMockInterfaceObject>();

        Assert.IsNotNull(resolvedObject);
    }
Ejemplo n.º 2
0
    public void DependencyContainer_ObjectReturnsNewInstanceIfLifetimeOptionsSetToTransiet()
    {
        DependencyContainer container = this.GetNewContainer();

        container.Register <IMockInterfaceObject, MockObject>(LifeTimeOptions.Transient);

        IMockInterfaceObject mockObject = container.Resolve <IMockInterfaceObject>();

        Guid   mockObjectId   = mockObject.ObjectId;
        string mockObjectName = mockObject.Name;

        mockObject = null;
        GC.Collect();
        Thread.Sleep(1000);

        mockObject = container.Resolve <IMockInterfaceObject>();

        Assert.IsNotNull(mockObject);
        Assert.AreNotEqual(mockObjectId, mockObject.ObjectId);
        Assert.AreNotEqual(mockObjectName, mockObject.Name);
    }
Ejemplo n.º 3
0
 public MockWithDependency(IMockInterfaceObject mockObject)
 {
     this.MockInterfaceObject = mockObject;
 }