Esempio n. 1
0
        public void CanHandleNoneOptionalValues()
        {
            var optional = DamlOptional.Of(None.Value);
            var maybe    = optional.Value;

            maybe.Should().BeOfType <None <Value> >();
            optional.IsEmpty.Should().BeTrue();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public void CanHandleNoneOptionalValues()
        {
            var optional = DamlOptional.Of(None.Value);
            var maybe    = optional.Value;

            Assert.AreEqual(typeof(None <Value>), maybe.GetType());
            Assert.IsTrue(optional.IsEmpty);
        }
Esempio n. 5
0
        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());
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 public void CanConvertBetweenProto()
 {
     ConvertThroughProto(DamlOptional.Of(null));
     ConvertThroughProto(DamlOptional.Of(new Int64(long.MaxValue)));
 }