コード例 #1
0
		public void ShouldCreateAndEvaluateTest()
		{
			SingletonWrapperDependencyResolution singletonWrapperDependencyResolution;
			IDependencyManager mockDependencyManager;
			IDependencyResolution mockDependencyResolution;
			IDependencyManager _unusedDependencyManager = null;
			Type _unusedType = null;
			string _unusedString = null;
			object result;
			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(11);
			Expect.On(mockDependencyResolution).One.Method(m => m.Dispose());

			singletonWrapperDependencyResolution = new SingletonWrapperDependencyResolution(mockDependencyResolution);

			Assert.AreEqual(DependencyLifetime.Singleton, singletonWrapperDependencyResolution.DependencyLifetime);

			// should be thawed at this point
			result = singletonWrapperDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty);

			Assert.IsNotNull(result);
			Assert.AreEqual(11, result);

			// should be frozen at this point
			result = singletonWrapperDependencyResolution.Resolve(mockDependencyManager, typeof(object), string.Empty);

			Assert.IsNotNull(result);
			Assert.AreEqual(11, result);

			singletonWrapperDependencyResolution.Dispose();

			mockFactory.VerifyAllExpectationsHaveBeenMet();
		}