File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed 
tests/DynamicObject.Tests Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ let hashDateTime (dt : System.DateTime) : int =
1515
1616
1717let  hash  obj  = 
18-     obj.GetHashCode() 
18+     if  obj =  null  then  
19+         0 
20+     else 
21+         obj.GetHashCode() 
1922
2023let  boxHashOption   ( a :  'a option )  :  obj  = 
2124    if  a.IsSome then  a.Value.GetHashCode()  else  ( 0 ) .GetHashCode() 
Original file line number Diff line number Diff line change @@ -535,6 +535,21 @@ let tests_GetHashCode = testList "GetHashCode" [
535535        b2.SetProperty( " c" ,  2 ) 
536536        a2.SetProperty( " b" ,  b2) 
537537        Expect.equal ( a.GetHashCode())  ( a2.GetHashCode())  " Values should be equal" 
538+ 
539+     testCase " null Value same key" <|  fun  _  -> 
540+         let  a  =  DynamicObj() 
541+         a.SetProperty( " b" ,  null ) 
542+         let  b  =  DynamicObj() 
543+         b.SetProperty( " b" ,  null ) 
544+         Expect.equal ( a.GetHashCode())  ( b.GetHashCode())  " Values should be equal" 
545+ 
546+     testCase " null Value different key" <|  fun  _  -> 
547+         let  a  =  DynamicObj() 
548+         a.SetProperty( " b" ,  null ) 
549+         let  b  =  DynamicObj() 
550+         a.SetProperty( " c" ,  null ) 
551+         Expect.notEqual ( a.GetHashCode())  ( b.GetHashCode())  " Values should not be equal" 
552+ 
538553] 
539554
540555let  main  =  testList " DynamicObj (Class)" [ 
Original file line number Diff line number Diff line change @@ -68,6 +68,13 @@ let tests_remove = testList "Remove" [
6868
6969        Expect.equal p.FirstName null  " Static property should " 
7070
71+     testCase " Remove Static HashCodeDoesNotFail" <|  fun  _  -> 
72+         let  p  =  Person( " 123" , " John" ) 
73+ 
74+         p.RemoveProperty( " FirstName" )  |>  ignore
75+         
76+         p.GetHashCode()  |>  ignore
77+ 
7178    testCase " Remove Static Immutable" <|  fun  _  -> 
7279        let  p  =  Person( " 123" , " John" ) 
7380        let  f  =  fun   ()  -> ( " Id" )  |>  ignore
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments