Ejemplo n.º 1
0
 public void Passing_Null_ErrorSelector_Throws()
 {
     Assert.Throws <ArgumentNullException>(
         AssertionUtilities.ErrorSelectorName,
         () => AssertionUtilities.GetGenderAsync(2).SafeCast <int>(null)
         );
 }
Ejemplo n.º 2
0
 public async Task Result_With_Error_Using_Invalid_Cast_Expects_No_Exception()
 {
     const int identity = 3;
     await AssertionUtilities
     .GetGenderAsync(identity)
     .Cast <string>()
     .AssertError("Could not determine gender.");
 }
Ejemplo n.º 3
0
 public async Task Result_With_Value_Using_Valid_Cast_Expects_Value_As_Int()
 {
     const int identity = 0;
     await AssertionUtilities
     .GetGenderAsync(identity)
     .Cast <int>()
     .AssertValue(identity);
 }
Ejemplo n.º 4
0
        public Task With_Error_Double_Type_Throws()
        {
            var result = AssertionUtilities.GetGenderAsync(int.MaxValue).Map(x => (int)x);

            return(Assert.ThrowsAsync <InvalidCastException>(
                       async() => await result.FullCast <AssertionUtilities.Gender, AssertionUtilities.Error>()
                       ));
        }
Ejemplo n.º 5
0
        public void Result_With_Value_Using_Valid_Cast_Expects_Value_As_Int()
        {
            const int identity = 0;

            AssertionUtilities
            .GetGenderAsync(identity)
            .SafeCast <int>(gender => "ERROR")
            .AssertValue(identity);
        }
Ejemplo n.º 6
0
        public void Result_With_Error_Using_Valid_Cast_Expects_Error()
        {
            const int identity = 3;

            AssertionUtilities
            .GetGenderAsync(identity)
            .SafeCast <int>(gender => "ERROR")
            .AssertError("Could not determine gender.");
        }
Ejemplo n.º 7
0
        public void With_Valid_Value_Valid_Cast_Double_Type()
        {
            var result = AssertionUtilities.GetGenderAsync(0).Map(x => (int)x);

            Assert.Null(
                Record.Exception(
                    () => result.FullCast <AssertionUtilities.Gender, AssertionUtilities.Error>()
                    )
                );
        }
Ejemplo n.º 8
0
 public async Task Result_With_Value_Using_Invalid_Cast_Expects_Cast_Exception()
 {
     const int identity = 0;
     await Assert.ThrowsAsync <InvalidCastException>(async() =>
                                                     await AssertionUtilities.GetGenderAsync(identity).Cast <string>());
 }
Ejemplo n.º 9
0
 public void Result_With_Value_Using_Invalid_Cast_Expects_Cast_Exception()
 {
     AssertionUtilities.GetGenderAsync(0)
     .SafeCast <int>(gender => "ERROR");
 }