public void UnionGeneratesCorrectType() { TSParameter firstParameter = new TSParameter("Name", "Type", "description"); TSParameter secondParameter = new TSParameter("Name", "OtherType", "description"); TSParameter thirdParameter = new TSParameter("Name", "Type", "description"); TSParameter union = TSParameter.Union(firstParameter, secondParameter, thirdParameter); Assert.AreEqual("Type | OtherType", union.Type); }
public void UnionGeneratesCorrectDescription() { TSParameter firstParameter = new TSParameter("Name", "Type", "The description"); TSParameter secondParameter = new TSParameter("Name", "Type", "Some other Description"); TSParameter thirdParameter = new TSParameter("Name", "Type", "Third description"); TSParameter union = TSParameter.Union(firstParameter, secondParameter, thirdParameter); Assert.AreEqual("The description or some other Description or third description", union.Description); }
public void UnionGeneratesCorrectName() { TSParameter firstParameter = new TSParameter("Name", "Type", "description"); TSParameter secondParameter = new TSParameter("otherName", "Type", "description"); TSParameter thirdParameter = new TSParameter("moreComplicatedName", "Type", "description"); TSParameter union = TSParameter.Union(firstParameter, secondParameter, thirdParameter); Assert.AreEqual("nameOrOtherNameOrMoreComplicatedName", union.Name); }
public static TSParameter Union(params TSParameter[] parameters) { return(TSParameter.Union(parameters, null, null, null, null)); }
/// <summary> /// Add a parameter to this parameter list. /// </summary> /// <param name="parameter">The parameter to add.</param> public void Parameter(TSParameter parameter) { Parameter(parameter.Name, parameter.Type, !parameter.Required); }
public void UnionThrowsIfOneElementPassed() { Assert.ThrowsException <ArgumentException>(() => TSParameter.Union(new TSParameter("name", "type", "description"))); }
public void UnionThrowsIfNoElementsPassed() { Assert.ThrowsException <ArgumentException>(() => TSParameter.Union(new TSParameter[] { })); }
public void ConstructorShouldUnionizeTypesProperly() { TSParameter parameter = new TSParameter("parameterName", new[] { "MyType", "AnotherType", "OneMoreType" }, "description"); Assert.AreEqual("MyType | AnotherType | OneMoreType", parameter.Type); }
public void ConstructorShouldSetSingleTypeProperly() { TSParameter parameter = new TSParameter("parameterName", new[] { "MyType" }, "description"); Assert.AreEqual("MyType", parameter.Type); }