public void DIBinding_To_IsReferenceTypeException() { // Arrange var actual = false; var instance = new TestStruct(); var reflector = new Reflector(); var container = new DiContainer(); var key = typeof(Test); var binding = new DiBinding(reflector, container, key, null, null); binding.InGlobal(); // Act try { binding.To(instance); } catch (ArgumentException) { actual = true; } // Assert Assert.IsTrue(actual); }
public void DIBinding_To_ToException() { // Arrange var actual = false; var instance = new Test(null); var reflector = new Reflector(); var container = new DiContainer(); var key = typeof(Test); var binding = new DiBinding(reflector, container, key, null, null); binding.InGlobal().To(instance); // Act try { binding.To(instance); } catch (InvalidOperationException) { actual = true; } // Assert Assert.IsTrue(actual); }
public void DIBinding_ToGeneric_NotLifeTimeException() { // Arrange var actual = false; var reflector = new Reflector(); var container = new DiContainer(); var key = typeof(Test); var binding = new DiBinding(reflector, container, key, null, null); // Act try { binding.To <Test>(); } catch (InvalidOperationException) { actual = true; } // Assert Assert.IsTrue(actual); }