public void CreateOptionType()
        {
            var typeName = "Option";

            var du = new DiscriminatedUnion(
                typeName,
                new SimpleDiscriminatedUnionCase("None", typeName),
                new ParameterisedDiscriminatedUnionCase("Some", typeName, "object"));

            var typeDefinition = du.ToString();
            WriteToFile(typeName, typeDefinition);
        }
        public void CreateShapeType()
        {
            var typeName = "Shape";

            var du = new DiscriminatedUnion(
                typeName,
                new SimpleDiscriminatedUnionCase("Point", typeName),
                new ParameterisedDiscriminatedUnionCase("Line", typeName, "int"),
                new ParameterisedDiscriminatedUnionCase(
                    "Square",
                    typeName,
                    Tuple.Create("Width", "int"),
                    Tuple.Create("Height", "int")),
                new ParameterisedDiscriminatedUnionCase(
                    "Cube",
                    typeName,
                    Tuple.Create("Width", "int"),
                    Tuple.Create("Height", "int"),
                    Tuple.Create("Depth", "int")));

            var typeDefinition = du.ToString();
            WriteToFile(typeName, typeDefinition);
        }
Exemple #3
0
    public void DiscriminatedUnion_ToString()
    {
        DiscriminatedUnion <string, string>?du = DiscriminatedUnion <string, string> .CreateA("foo");

        Assert.Equal(du.ToString(), "foo");
    }