Beispiel #1
0
 public void Passing_Null_ErrorSelector_Throws()
 {
     Assert.Throws <ArgumentNullException>(
         AssertionUtilities.ErrorSelectorName,
         () => AssertionUtilities.GetGender(2).SafeCast <int>(null)
         );
 }
Beispiel #2
0
        public void With_Error_Double_Type_Throws()
        {
            var result = AssertionUtilities.GetGender(int.MaxValue).Map(x => (int)x);

            Assert.Throws <InvalidCastException>(
                () => result.FullCast <AssertionUtilities.Gender, AssertionUtilities.Error>()
                );
        }
Beispiel #3
0
        public void Result_With_Error_Using_Invalid_Cast_Expects_No_Exception()
        {
            const int identity = 3;

            AssertionUtilities
            .GetGender(identity)
            .Cast <string>()
            .AssertError("Could not determine gender.");
        }
Beispiel #4
0
        public void Result_With_Value_Using_Valid_Cast_Expects_Value_As_Int()
        {
            const int identity = 0;

            AssertionUtilities
            .GetGender(identity)
            .Cast <int>()
            .AssertValue(identity);
        }
Beispiel #5
0
        public void Result_With_Error_Using_Valid_Cast_Expects_Error()
        {
            const int identity = 3;

            AssertionUtilities
            .GetGender(identity)
            .SafeCast <int>(gender => "ERROR")
            .AssertError("Could not determine gender.");
        }
Beispiel #6
0
        public void With_Valid_Value_Valid_Cast_Double_Type()
        {
            var result = AssertionUtilities.GetGender(0).Map(x => (int)x);

            Assert.Null(
                Record.Exception(
                    () => result.FullCast <AssertionUtilities.Gender, AssertionUtilities.Error>()
                    )
                );
        }
Beispiel #7
0
        public void Result_With_Value_Using_Invalid_Cast_Expects_Cast_Exception()
        {
            const int identity = 0;

            Assert.Throws <InvalidCastException>(() => AssertionUtilities.GetGender(identity).Cast <string>());
        }
Beispiel #8
0
 public void Result_With_Value_Using_Invalid_Cast_Expects_Cast_Exception()
 {
     AssertionUtilities.GetGender(0)
     .SafeCast <int>(gender => "ERROR");
 }