Esempio n. 1
0
		public void ShareTest()
		{
			SingletonLifestyle lifestyle = new SingletonLifestyle();

			object instance = lifestyle.Locate((x, y) => new BasicService(),
				new FauxInjectionScope(),
				new FauxInjectionContext(),
				new FauxExportStrategy(() => new object()));

			Assert.NotNull(instance);

			object instance2 = lifestyle.Locate((x, y) => new BasicService(),
				new FauxInjectionScope(),
				new FauxInjectionContext(),
				new FauxExportStrategy(() => new object()));

			Assert.True(ReferenceEquals(instance, instance2));
		}
Esempio n. 2
0
		public void DisposeTest()
		{
			SingletonLifestyle lifestyle = new SingletonLifestyle();

			IDisposableService disposableService =
				(IDisposableService)
					lifestyle.Locate((x, y) => new DisposableService(),
						new FauxInjectionScope(),
						new FauxInjectionContext(),
						new FauxExportStrategy(() => new object()));

			bool eventCalled = false;

			disposableService.Disposing += (sender, args) => eventCalled = true;

			lifestyle.Dispose();

			Assert.True(eventCalled);
		}