コード例 #1
0
        public async Task Return_CorrectJSON_When_ScreenNameIsValid()
        {
            // Arrange
            this.apiProviderStub
            .Setup(x => x.GetJSON(It.IsAny <string>()))
            .ReturnsAsync("correctJSON");

            var twitterService = new global::RTWTR.Service.Twitter.TwitterService(
                this.apiProviderStub.Object,
                this.jsonProviderStub.Object,
                this.mappingProviderStub.Object
                );

            var result = await twitterService.GetSingleUserJSONAsync("screenName");

            Assert.AreEqual(
                "correctJSON",
                result
                );
        }
コード例 #2
0
        public async Task Return_EmptyString_When_ResponseIsNull()
        {
            // Arrange
            this.apiProviderStub
            .Setup(x => x.GetJSON(It.IsAny <string>()))
            .ReturnsAsync((string)null);

            var twitterService = new global::RTWTR.Service.Twitter.TwitterService(
                this.apiProviderStub.Object,
                this.jsonProviderStub.Object,
                this.mappingProviderStub.Object
                );

            // Act
            var result = await twitterService.GetSingleUserJSONAsync("screenName");

            // Assert
            Assert.AreEqual(
                string.Empty,
                result
                );
        }
コード例 #3
0
        public async Task Call_ApiProvider_GetJSON_Once()
        {
            // Arrange
            this.apiProviderStub
            .Setup(x => x.GetJSON(It.IsAny <string>()))
            .ReturnsAsync("correctJSON")
            .Verifiable();

            var twitterService = new global::RTWTR.Service.Twitter.TwitterService(
                this.apiProviderStub.Object,
                this.jsonProviderStub.Object,
                this.mappingProviderStub.Object
                );

            // Act
            var result = await twitterService.GetSingleUserJSONAsync("screenName");

            // Assert
            this.apiProviderStub.Verify(
                x => x.GetJSON(It.IsAny <string>()),
                Times.Once
                );
        }