public void Create_TypeWithDefaultConstructor_ReturnsNewInstance() { var subject = new ServiceCreator(); object result = subject.Create(typeof(StringBuilder), _containerMock.Object); Assert.NotNull(result); Assert.IsInstanceOf<StringBuilder>(result); }
public void Create_Interface_ThrowsException() { var subject = new ServiceCreator(); Assert.Throws<InvalidOperationException>(() => { subject.Create(typeof(IDisposable), _containerMock.Object); }); }
public void Create_ArgumentsCannotBeResolved_ThrowsException() { var subject = new ServiceCreator(); Assert.Throws<InvalidOperationException>(() => { subject.Create(typeof(SetupMatcher), _containerMock.Object); }); }
public void Create_MultipleValidConstructors_SelectsConstructorWithMostParameters(string value) { object instance = value; _containerMock .Setup(container => container.TryResolve(typeof(string), out instance)) .Returns(true); var subject = new ServiceCreator(); TestClass result = (TestClass)subject.Create(typeof(TestClass), _containerMock.Object); Assert.AreEqual(value, result.First); Assert.AreEqual(value, result.Second); }