public void ObjectBuilder_TypeWithDefaultConstructor_CanBeBuilt() { var ob = new ObjectBuilderIL(GetServiceProviderMock()); var o = ob.BuildObject <ObjToBuild_DefaultConstructor>(); Assert.NotNull(o); }
public void ObjectBuilder_TypeWithEmptyPrimaryConstructor_CanBeBuilt() { var ob = new ObjectBuilderIL(GetServiceProviderMock()); var o = ob.BuildObject <ObjToBuild_EmptyPrimaryConstructor>(); Assert.NotNull(o); Assert.Equal("_", o.S); }
public void ObjectBuilder_TypeWithTwoConstructorsAndNoPrimaryConstructor_ThrowsException() { bool error = false; try { var ob = new ObjectBuilderIL(GetServiceProviderMock()); var o = ob.BuildObject <ObjToBuild_NoPrimaryConstructor>(); } catch (Exception ex) { error = ex.Message.StartsWith("Cannot find constructor for", StringComparison.Ordinal); } Assert.True(error); }
public void ObjectBuilder_NullType_ThrowsException() { bool error = false; try { var ob = new ObjectBuilderIL(GetServiceProviderMock()); ob.BuildObject(null); } catch (ArgumentNullException) { error = true; } Assert.True(error); }