コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public static TSParameter Union(params TSParameter[] parameters)
 {
     return(TSParameter.Union(parameters, null, null, null, null));
 }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
 public void UnionThrowsIfOneElementPassed()
 {
     Assert.ThrowsException <ArgumentException>(() => TSParameter.Union(new TSParameter("name", "type", "description")));
 }
コード例 #7
0
 public void UnionThrowsIfNoElementsPassed()
 {
     Assert.ThrowsException <ArgumentException>(() => TSParameter.Union(new TSParameter[] { }));
 }
コード例 #8
0
        public void ConstructorShouldUnionizeTypesProperly()
        {
            TSParameter parameter = new TSParameter("parameterName", new[] { "MyType", "AnotherType", "OneMoreType" }, "description");

            Assert.AreEqual("MyType | AnotherType | OneMoreType", parameter.Type);
        }
コード例 #9
0
        public void ConstructorShouldSetSingleTypeProperly()
        {
            TSParameter parameter = new TSParameter("parameterName", new[] { "MyType" }, "description");

            Assert.AreEqual("MyType", parameter.Type);
        }