public void ShouldCreateAndEvaluateTest() { ContextWrapperDependencyResolution contextWrapperDependencyResolution; IDependencyManager mockDependencyManager; IDependencyResolution mockDependencyResolution; IDependencyManager _unusedDependencyManager = null; Type _unusedType = null; string _unusedString = null; object result; const int EXPECTED = 11; MockFactory mockFactory; mockFactory = new MockFactory(); mockDependencyManager = mockFactory.CreateInstance<IDependencyManager>(); mockDependencyResolution = mockFactory.CreateInstance<IDependencyResolution>(); Expect.On(mockDependencyResolution).One.Method(m => m.Resolve(_unusedDependencyManager, _unusedType, _unusedString)).With(mockDependencyManager, typeof(object), string.Empty).WillReturn(EXPECTED); Expect.On(mockDependencyResolution).One.Method(m => m.Dispose()); contextWrapperDependencyResolution = new ContextWrapperDependencyResolution(ContextScope.LocalThreadSafe, mockDependencyResolution); Assert.AreEqual(DependencyLifetime.Singleton, contextWrapperDependencyResolution.DependencyLifetime); // should be thawed at this point result = contextWrapperDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty); Assert.IsNotNull(result); Assert.AreEqual(EXPECTED, result); // should be frozen at this point result = contextWrapperDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty); Assert.IsNotNull(result); Assert.AreEqual(EXPECTED, result); contextWrapperDependencyResolution.Dispose(); mockFactory.VerifyAllExpectationsHaveBeenMet(); }
public void ShouldFailOnNullDependencyManagerResolveTest() { ContextWrapperDependencyResolution contextWrapperDependencyResolution; IDependencyManager mockDependencyManager; IDependencyResolution mockDependencyResolution; object result; MockFactory mockFactory; mockFactory = new MockFactory(); mockDependencyManager = null; mockDependencyResolution = mockFactory.CreateInstance<IDependencyResolution>(); contextWrapperDependencyResolution = new ContextWrapperDependencyResolution(ContextScope.LocalThreadSafe, mockDependencyResolution); result = contextWrapperDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty); }
public void ShouldFailOnNullTypeResolveUntypedTest() { ContextWrapperDependencyResolution<int> contextWrapperDependencyResolution; IDependencyManager mockDependencyManager; IDependencyResolution<int> mockDependencyResolution; object result; MockFactory mockFactory; mockFactory = new MockFactory(); mockDependencyManager = mockFactory.CreateInstance<IDependencyManager>(); mockDependencyResolution = mockFactory.CreateInstance<IDependencyResolution<int>>(); contextWrapperDependencyResolution = new ContextWrapperDependencyResolution<int>(ContextScope.LocalThreadSafe, mockDependencyResolution); result = contextWrapperDependencyResolution.Resolve(mockDependencyManager, null, string.Empty); }