public void Absent_FromUnit_ExpectAbsent() { var actual = Optional.Absent <string>(Unit.Value); var expected = Optional <string> .Absent; Assert.AreEqual(expected, actual); }
public Optional <Client> GetCurrentClient() { var client = GetClientInternal(); // return Optional<Client>.Of(client); // return client.ToOptional(); return(Optional <Client> .Absent()); }
public static Optional <T> ToOptional <T>(this T obj) { if (obj == null) { return(Optional <T> .Absent()); } return(Optional <T> .Of(obj)); }
public void TaggedUnion_ToOptional_UnionIsDefault_ExpectAbsent() { var union = default(TaggedUnion <StructType, Unit>); var actual = union.ToOptional(); var expected = Optional.Absent <StructType>(); Assert.AreEqual(expected, actual); }
public void Optional_ToTaggedUnion_OptionalIsAbsent_ExpectActualIsSecond() { var optional = Optional.Absent <RefType>(); var actual = optional.ToTaggedUnion(); var expected = TaggedUnion <RefType, Unit> .Second(Unit.Value); Assert.AreEqual(expected, actual); }
public void TaggedUnion_ToOptional_UnionIsSecond_ExpectAbsent() { var union = TaggedUnion <RefType, Unit> .Second(Unit.Value); var actual = union.ToOptional(); var expected = Optional.Absent <RefType>(); Assert.AreEqual(expected, actual); }