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.GetTwitterUsersByScreenName(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.GetTwitterUsersByScreenName("Pesho"); //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 <FolloweeFromApiDto[]>(It.IsAny <string>())).Returns(new FolloweeFromApiDto[0]); //Act var result = sut.GetTwitterUsersByScreenName("Pesho"); //Assert Assert.IsInstanceOfType(result, typeof(IEnumerable <FolloweeFromApiDto>)); }
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 <FolloweeFromApiDto[]>(It.IsAny <string>())).Returns(new FolloweeFromApiDto[0]); //Act var result = sut.GetTwitterUsersByScreenName("Pesho"); //Assert jsonDerserializerMock.Verify(v => v.Deserialize <FolloweeFromApiDto[]>(It.IsAny <string>()), Times.Once); }