Esempio n. 1
0
        public async Task GetImagesAsync_NoErrorOccured_ReturnsResponse()
        {
            //Arrange
            messageHandlerMock.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.Is <HttpRequestMessage>(x =>
                                                                                             x.RequestUri.ToString().StartsWith(BASE_ADDRESS + API_VERSION + "/image")), ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(MockResponses.ReturnGetImageResponse()), Encoding.Default, "application/json")
            });
            //Act
            var result = await SUT.GetImageAsync(new ImageRequest());

            //Assert
            Assert.IsType <ImageResponse>(result);
        }
Esempio n. 2
0
        public async Task DeleteStreamAsync_NoErrorOccured_ReturnsResponse()
        {
            //Arrange
            messageHandlerMock.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.Is <HttpRequestMessage>(x =>
                                                                                             x.RequestUri.ToString() == BASE_ADDRESS + API_VERSION + "/deleteStream"), ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(MockResponses.ReturnDeleteStreamResponse()), Encoding.Default, "application/json")
            });
            //Act
            var result = await SUT.DeleteStreamAsync(new DeleteStreamRequest()
            {
                Name = "/4afdcb21ef149f06309573734e6d9515"
            });

            //Assert
            Assert.IsType <DeleteStreamResponse>(result);
        }
Esempio n. 3
0
        public async Task FetchStreamAsync_NoErrorOccured_ReturnsResponse()
        {
            //Arrange
            messageHandlerMock.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.Is <HttpRequestMessage>(x =>
                                                                                             x.RequestUri.ToString() == BASE_ADDRESS + API_VERSION + "/fetchStream"), ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(MockResponses.ReturnFetchStreamResponse()), Encoding.Default, "application/json")
            });
            //Act
            var result = await SUT.FetchStreamAsync(new FetchStreamRequest()
            {
                From = "http://example.com/img.png", TargetPath = "/", Filename = "name-of-stream.mp4"
            });

            //Assert
            Assert.IsType <FetchStreamResponse>(result);
        }
Esempio n. 4
0
        public async Task FinalizeStreamAsync_NoErrorOccured_ReturnsResponse()
        {
            //Arrange
            messageHandlerMock.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.Is <HttpRequestMessage>(x =>
                                                                                             x.RequestUri.ToString() == BASE_ADDRESS + API_VERSION + "/finalizeStream"), ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(MockResponses.ReturnFinalizeStreamResponse()), Encoding.Default, "application/json")
            });
            //Act
            var result = await SUT.FinalizeStreamAsync(new FinalizeStreamRequest()
            {
                FileName = "/filename.mp4", Token = "uploadToken"
            });

            //Assert
            Assert.IsType <FinalizeStreamResponse>(result);
        }