public void ShouldHandleFail() { var err = new DefaultClass { IntValue = -1, StringValue = "test error Message" }; var result = Result.Failure <DefaultClass, DefaultClass>(err); var serialized = MessagePackSerializer.Serialize(result, _options); var deserialized = MessagePackSerializer.Deserialize <Result <DefaultClass, DefaultClass> >(serialized, _options); Assert.False(deserialized.IsSuccess); Assert.True(deserialized.IsFailure); }
public void ShouldHandleHasValue() { var obj = new DefaultClass { IntValue = 42, StringValue = "test str" }; var result = Maybe <DefaultClass> .From(obj); var serialized = MessagePackSerializer.Serialize(result, _options); var deserialized = MessagePackSerializer.Deserialize <Maybe <DefaultClass> >(serialized, _options); Assert.True(deserialized.HasValue); }
public void ShouldHandleOk() { var obj = new DefaultClass { IntValue = 42, StringValue = "test str" }; var result = Result.Success <DefaultClass, DefaultClass>(obj); var serialized = MessagePackSerializer.Serialize(result, _options); var deserialized = MessagePackSerializer.Deserialize <Result <DefaultClass, DefaultClass> >(serialized, _options); Assert.True(deserialized.IsSuccess); Assert.False(deserialized.IsFailure); }