Beispiel #1
0
        public void Do_not_throw_on_abuse_of_Equals()
        {
            MaybeThrows <TestClass> maybe1 = MaybeThrows <TestClass> .None;

            // ReSharper disable once SuspiciousTypeConversion.Global
            bool result = maybe1.Equals("Bad");

            Assert.False(result);
        }
Beispiel #2
0
        public void MaybeThrows_None_and_MaybeThrows_None_are_equal()
        {
            MaybeThrows <TestClass> maybe1 = MaybeThrows <TestClass> .None;
            MaybeThrows <TestClass> maybe2 = MaybeThrows <TestClass> .None;

            bool result = maybe1.Equals(maybe2);

            Assert.True(result);
        }
Beispiel #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);
        }
Beispiel #4
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);
        }