public void CanHandleOptionalValues() { var optional = DamlOptional.Of(Optional.Of((Value) new Text("hello"))); var maybe = optional.Value; maybe.Should().BeOfType <Some <Value> >(); optional.IsEmpty.Should().BeFalse(); }
private void ConvertThroughProto(DamlOptional source) { Com.Daml.Ledger.Api.V1.Value protoValue = source.ToProto(); var maybe = Value.FromProto(protoValue).AsOptional(); maybe.Should().BeOfType <Some <DamlOptional> >(); Assert.True(source == (Some <DamlOptional>)maybe); }
private void ConvertThroughProto(DamlOptional source) { Com.DigitalAsset.Ledger.Api.V1.Value protoValue = source.ToProto(); var maybe = Value.FromProto(protoValue).AsOptional(); Assert.AreEqual(typeof(Some <DamlOptional>), maybe.GetType()); Assert.IsTrue(source == (Some <DamlOptional>)maybe); }
public void CanHandleNoneOptionalValues() { var optional = DamlOptional.Of(None.Value); var maybe = optional.Value; maybe.Should().BeOfType <None <Value> >(); optional.IsEmpty.Should().BeTrue(); }
public void CanHandleOptionalValues() { var optional = DamlOptional.Of(Optional.Of((Value) new Text("hello"))); var maybe = optional.Value; Assert.AreEqual(typeof(Some <Value>), maybe.GetType()); Assert.IsFalse(optional.IsEmpty); }
public void CanHandleNoneOptionalValues() { var optional = DamlOptional.Of(None.Value); var maybe = optional.Value; Assert.AreEqual(typeof(None <Value>), maybe.GetType()); Assert.IsTrue(optional.IsEmpty); }
public void HashCodeHasValueSemantics() { var optional1 = DamlOptional.Of(new Int64(long.MaxValue)); var optional2 = DamlOptional.Of(new Int64(long.MinValue)); var optional3 = DamlOptional.Of(new Int64(long.MaxValue)); Assert.True(optional1.GetHashCode() == optional3.GetHashCode()); Assert.True(optional1.GetHashCode() != optional2.GetHashCode()); }
public void EqualityHasValueSemantics() { var optional1 = DamlOptional.Of(new Int64(long.MaxValue)); var optional2 = DamlOptional.Of(new Int64(long.MinValue)); var optional3 = DamlOptional.Of(new Int64(long.MaxValue)); Assert.True(optional1.Equals(optional1)); Assert.True(optional1 == optional1); Assert.True(optional1.Equals(optional3)); Assert.True(optional1 == optional3); Assert.False(optional1.Equals(optional2)); Assert.True(optional1 != optional2); }
public void CanConvertBetweenProto() { ConvertThroughProto(DamlOptional.Of(null)); ConvertThroughProto(DamlOptional.Of(new Int64(long.MaxValue))); }