Exemplo n.º 1
0
        public void ToDebugString_returns_debug_string()
        {
            MaybeThrows <string> maybe2 = MaybeThrows <string> .None;
            MaybeThrows <string> maybe3 = MaybeThrows <string> .Has("test");

            Assert.Equal("HasValue: False, Value: ", maybe2.ToDebugString());
            Assert.Equal("HasValue: True, Value: test", maybe3.ToDebugString());
        }
Exemplo n.º 2
0
        public void Has_Value_should_equal_set_value()
        {
            TestClass testClass = new TestClass();

            MaybeThrows <TestClass> maybe = MaybeThrows <TestClass> .Has(testClass);

            Assert.Equal(testClass, maybe.Value);
        }
Exemplo n.º 3
0
        public void Equals_should_return_false_if_HasValue_false_and_HasValue_true_even_if_values_are_equal()
        {
            MaybeThrows <int> maybe1 = MaybeThrows <int> .Has(0);

            MaybeThrows <int> maybe2 = MaybeThrows <int> .None;

            bool result = maybe1.Equals(maybe2);

            Assert.False(result);
        }
Exemplo n.º 4
0
        public void MaybeThrows_cast_to_T_should_return_value_of_T()
        {
            TestClass testClass = new TestClass();

            MaybeThrows <TestClass> maybe = MaybeThrows <TestClass> .Has(testClass);

            TestClass returned = (TestClass)maybe;

            Assert.Equal(testClass, returned);
        }
Exemplo n.º 5
0
        public void Non_equality_operator_should_compare_values()
        {
            string value1 = "1";
            string value2 = "2";
            string value3 = "2";

            MaybeThrows <string> maybe1 = MaybeThrows <string> .Has(value1);

            MaybeThrows <string> maybe2 = MaybeThrows <string> .Has(value2);

            MaybeThrows <string> maybe3 = MaybeThrows <string> .Has(value3);

            bool results1 = maybe1 != maybe2;
            bool results2 = maybe2 != maybe3;

            Assert.True(results1);
            Assert.False(results2);
        }
Exemplo n.º 6
0
        public void Equals_should_compare_values()
        {
            string value1 = "1";
            string value2 = "1";
            string value3 = "2";

            MaybeThrows <string> maybe1 = MaybeThrows <string> .Has(value1);

            MaybeThrows <string> maybe2 = MaybeThrows <string> .Has(value2);

            MaybeThrows <string> maybe3 = MaybeThrows <string> .Has(value3);

            bool result1 = maybe1.Equals(maybe2);
            bool result2 = maybe2.Equals(maybe3);

            Assert.True(result1);
            Assert.False(result2);
        }
Exemplo n.º 7
0
 public void Has_set_to_null_throws_NullReferenceException()
 {
     Assert.Throws <NullReferenceException>(() => MaybeThrows <TestClass> .Has(null));
 }
Exemplo n.º 8
0
        public void Has_HasValue_should_be_true()
        {
            MaybeThrows <TestClass> maybe = MaybeThrows <TestClass> .Has(new TestClass());

            Assert.True(maybe.HasValue);
        }
Exemplo n.º 9
0
 public void Has_is_type_of_MaybeThrows()
 {
     Assert.IsType <MaybeThrows <TestClass> >(MaybeThrows <TestClass> .Has(new TestClass()));
 }
Exemplo n.º 10
0
        public void ToString_with_HasValue_true_returns_value_as_string()
        {
            MaybeThrows <string> maybe = MaybeThrows <string> .Has("Hello");

            Assert.Equal("Hello", maybe.ToString());
        }