예제 #1
0
        public async Task Translate_ParameterIsNull_ThrowsNullReferenceException()
        {
            var giphy = new Giphy("test");

            TranslateParameter search = null;

            _ = await Assert.ThrowsAsync <NullReferenceException>(() => giphy.Translate(search));
        }
예제 #2
0
        public async Task Translate_NotSuccessStatusCode_ThrowsHttpRequestException()
        {
            var mockHttpHandler = HttpHandler.GetMockFailedHttpHandlerObject();
            var giphy           = new Giphy(mockHttpHandler);
            var search          = new TranslateParameter {
                Query = "test"
            };

            _ = await Assert.ThrowsAsync <HttpRequestException>(() => giphy.Translate(search));
        }
예제 #3
0
        public async Task Translate_QueryNotSpecified_ThrowsFormatException()
        {
            var giphy = new Giphy("test");

            //  The query variable was not set in the paramter model
            //  which is required to run a query on giphy's api
            var search = new TranslateParameter();

            _ = await Assert.ThrowsAsync <FormatException>(() => giphy.Translate(search));
        }
예제 #4
0
        public async Task Translate_WeirdnessOutOfRange_ThrowsFormatException(int value)
        {
            var giphy = new Giphy("test");

            var search = new TranslateParameter
            {
                Query     = "test",
                Weirdness = value
            };

            _ = await Assert.ThrowsAsync <FormatException>(() => giphy.Translate(search));
        }
예제 #5
0
        public async Task Translate_WhenCalled_ReturnsGiphySingle()
        {
            var mockHttpHandler = HttpHandler.GetMockSuccessHttpHandlerObject();
            var giphy           = new Giphy(mockHttpHandler);
            var search          = new TranslateParameter {
                Query = "test"
            };

            var actual = await giphy.Translate(search);

            Assert.NotNull(actual);
            Assert.IsType <GiphySingle>(actual);
        }