@@ -597,8 +597,119 @@ public void ApiCall_GetError_NullOn404()
597597
598598 // Act and Assert
599599 var actual = CoreHelper . RunTask ( apiCall ) ;
600+ Assert . Null ( actual ) ;
601+ }
602+
603+ [ Test ]
604+ public void ApiCall_GetModel_MissingContent ( )
605+ {
606+ //Arrange
607+ var url = "/apicall/get/model/missingContent" ;
608+
609+ handlerMock . When ( GetCompleteUrl ( url ) )
610+ . Respond ( HttpStatusCode . NoContent , new ByteArrayContent ( Array . Empty < byte > ( ) ) ) ;
611+
612+ var apiCall = CreateSimpleApiCall < ServerResponse > ( )
613+ . RequestBuilder ( requestBuilderAction => requestBuilderAction . Setup ( HttpMethod . Get , url ) )
614+ . ExecuteAsync ( ) ;
615+
616+ // Act and Assert
617+ var actual = CoreHelper . RunTask ( apiCall ) ;
618+ Assert . Null ( actual ) ;
619+ }
620+
621+ [ Test ]
622+ public void ApiCall_GetString_MissingContent ( )
623+ {
624+ //Arrange
625+ var url = "/apicall/get/string/missingContent" ;
626+
627+ handlerMock . When ( GetCompleteUrl ( url ) )
628+ . Respond ( HttpStatusCode . NoContent , new ByteArrayContent ( Array . Empty < byte > ( ) ) ) ;
629+
630+ var apiCall = CreateSimpleApiCall < string > ( )
631+ . RequestBuilder ( requestBuilderAction => requestBuilderAction . Setup ( HttpMethod . Get , url ) )
632+ . ExecuteAsync ( ) ;
633+
634+ // Act and Assert
635+ var actual = CoreHelper . RunTask ( apiCall ) ;
636+ Assert . Null ( actual ) ;
637+ }
638+
639+ [ Test ]
640+ public void ApiCall_GetNumber_MissingContent ( )
641+ {
642+ //Arrange
643+ var url = "/apicall/get/number/missingContent" ;
644+
645+ handlerMock . When ( GetCompleteUrl ( url ) )
646+ . Respond ( HttpStatusCode . NoContent , new ByteArrayContent ( Array . Empty < byte > ( ) ) ) ;
647+
648+ var apiCall = CreateSimpleApiCall < int > ( )
649+ . RequestBuilder ( requestBuilderAction => requestBuilderAction . Setup ( HttpMethod . Get , url ) )
650+ . ResponseHandler ( resHandlerAction => resHandlerAction . Deserializer ( res => int . Parse ( res ) ) )
651+ . ExecuteAsync ( ) ;
600652
653+ // Act and Assert
654+ var exp = Assert . Throws < FormatException > ( ( ) => CoreHelper . RunTask ( apiCall ) ) ;
655+ Assert . AreEqual ( "Input string was not in a correct format." , exp . Message ) ;
656+ }
657+
658+ [ Test ]
659+ public void ApiCall_GetNullableNumber_MissingContent ( )
660+ {
661+ //Arrange
662+ var url = "/apicall/get/nullableNumber/missingContent" ;
663+
664+ handlerMock . When ( GetCompleteUrl ( url ) )
665+ . Respond ( HttpStatusCode . NoContent , new ByteArrayContent ( Array . Empty < byte > ( ) ) ) ;
666+
667+ var apiCall = CreateSimpleApiCall < int ? > ( )
668+ . RequestBuilder ( requestBuilderAction => requestBuilderAction . Setup ( HttpMethod . Get , url ) )
669+ . ResponseHandler ( resHandlerAction => resHandlerAction . Deserializer ( res => int . Parse ( res ) ) )
670+ . ExecuteAsync ( ) ;
671+
672+ // Act and Assert
673+ var actual = CoreHelper . RunTask ( apiCall ) ;
601674 Assert . Null ( actual ) ;
602675 }
676+
677+ [ Test ]
678+ public void ApiCall_GetNullableNumber_WhiteSpaceContent ( )
679+ {
680+ //Arrange
681+ var url = "/apicall/get/nullableNumber/whiteSpacedContent" ;
682+
683+ handlerMock . When ( GetCompleteUrl ( url ) )
684+ . Respond ( HttpStatusCode . NoContent , new StringContent ( " " ) ) ;
685+
686+ var apiCall = CreateSimpleApiCall < int ? > ( )
687+ . RequestBuilder ( requestBuilderAction => requestBuilderAction . Setup ( HttpMethod . Get , url ) )
688+ . ResponseHandler ( resHandlerAction => resHandlerAction . Deserializer ( res => int . Parse ( res ) ) )
689+ . ExecuteAsync ( ) ;
690+
691+ // Act and Assert
692+ var actual = CoreHelper . RunTask ( apiCall ) ;
693+ Assert . Null ( actual ) ;
694+ }
695+
696+ [ Test ]
697+ public void ApiCall_GetNullableNumber_WithContent ( )
698+ {
699+ //Arrange
700+ var url = "/apicall/get/nullableNumber/withContent" ;
701+
702+ handlerMock . When ( GetCompleteUrl ( url ) )
703+ . Respond ( HttpStatusCode . OK , new StringContent ( "123" ) ) ;
704+
705+ var apiCall = CreateSimpleApiCall < int ? > ( )
706+ . RequestBuilder ( requestBuilderAction => requestBuilderAction . Setup ( HttpMethod . Get , url ) )
707+ . ResponseHandler ( resHandlerAction => resHandlerAction . Deserializer ( res => int . Parse ( res ) ) )
708+ . ExecuteAsync ( ) ;
709+
710+ // Act and Assert
711+ var actual = CoreHelper . RunTask ( apiCall ) ;
712+ Assert . AreEqual ( 123 , actual ) ;
713+ }
603714 }
604715}
0 commit comments