public void StringValueCreatesOneOf() { var oo = new OneOf <int, string>("abc"); Assert.AreEqual("abc", oo.ToString()); }
public void IntValueCreatesOneOf() { var oo = new OneOf <int, string>(123); Assert.AreEqual("123", oo.ToString()); }
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()); }
public void TheValueAndTypeNameAreFormattedCorrectly() { OneOf <string, int, DateTime, decimal> a = 42; Assert.AreEqual("System.Int32: 42", a.ToString()); }