public void Throw_ArgumentNullException_When_Input_Is_Null() { //Arrange var apiCallerMock = Mock.Of <ITwitterApiCaller>(); var jsonDerserializerMock = Mock.Of <IJsonDeserializer>(); var sut = new TwitterApiCallService(apiCallerMock, jsonDerserializerMock); //Act && Assert Assert.ThrowsException <ArgumentNullException>(() => sut.GetTweetByTweetId(null)); }
public void Invoke_GetTwitterData_From_ApiCaller_When_Input_Is_Valid() { //Arrange var apiCallerMock = new Mock <ITwitterApiCaller>(); var jsonDerserializerMock = Mock.Of <IJsonDeserializer>(); var sut = new TwitterApiCallService(apiCallerMock.Object, jsonDerserializerMock); //Act var result = sut.GetTweetByTweetId("123"); //Assert apiCallerMock.Verify(v => v.GetTwitterData(It.IsAny <string>()), Times.Once); }
public void Return_Instance_Of_TypeFolloweeFromApiDtoArray_When_Input_Is_Valid() { //Arrange var apiCallerMock = new Mock <ITwitterApiCaller>(); var jsonDerserializerMock = new Mock <IJsonDeserializer>(); var sut = new TwitterApiCallService(apiCallerMock.Object, jsonDerserializerMock.Object); jsonDerserializerMock.Setup(s => s.Deserialize <TweetFromApiDto>(It.IsAny <string>())).Returns(new TweetFromApiDto()); //Act var result = sut.GetTweetByTweetId("123"); //Assert Assert.IsInstanceOfType(result, typeof(TweetFromApiDto)); }
public void Invoke_Deserialize_From_jsonDeserializer_When_Input_Is_Valid() { //Arrange var apiCallerMock = new Mock <ITwitterApiCaller>(); var jsonDerserializerMock = new Mock <IJsonDeserializer>(); var sut = new TwitterApiCallService(apiCallerMock.Object, jsonDerserializerMock.Object); jsonDerserializerMock.Setup(s => s.Deserialize <TweetFromApiDto>(It.IsAny <string>())).Returns(new TweetFromApiDto()); //Act var result = sut.GetTweetByTweetId("123"); //Assert jsonDerserializerMock.Verify(v => v.Deserialize <TweetFromApiDto>(It.IsAny <string>()), Times.Once); }