Exemple #1
0
        public void StringValueCreatesOneOf()
        {
            var oo = new OneOf <int, string>("abc");

            Assert.AreEqual("abc", oo.ToString());
        }
Exemple #2
0
        public void IntValueCreatesOneOf()
        {
            var oo = new OneOf <int, string>(123);

            Assert.AreEqual("123", oo.ToString());
        }
Exemple #3
0
        public void CallingToStringOnANestedNonRecursiveTypeWorks()
        {
            OneOf <OneOf <string, bool>, OneOf <bool, string> > nestedType = (OneOf <string, bool>)true;

            Assert.AreEqual("OneOf.OneOf`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: System.Boolean: True", nestedType.ToString());
        }
        public void StringValueImplicitlyConverted()
        {
            OneOf <int, string> oo = "abc";  // The value is implicitly converted to a OneOf before being assigned to "oo"

            Assert.AreEqual("abc", oo.ToString());
        }
Exemple #5
0
        public void TheValueAndTypeNameAreFormattedCorrectly()
        {
            OneOf <string, int, DateTime, decimal> a = 42;

            Assert.AreEqual("System.Int32: 42", a.ToString());
        }