Exemplo n.º 1
0
        public async Task WhenValidInputPassed_ReturnListofDeals()
        {
            //Arrage
            var productTypes = new List <string> {
                "Broadband"
            };
            var speed = "17";
            var data  = JsonConvert.SerializeObject(TestdataGenerator.CreateFakeBroadbandResult());

            var responseMessage = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(data, System.Text.Encoding.UTF8, "application/json"),
            };
            var messageHandler     = new FakeHttpMessageHandler(responseMessage);
            var _httpClientManager = new HttpClientManager(messageHandler);

            //Act
            var response = await _httpClientManager.GetBroadbandDeals(It.IsAny <string[]>(), It.IsAny <string>());

            // Assert
            Assert.IsTrue(response != null && response.Deals != null);
            Assert.IsTrue(response.Deals.Count > 0);
            Assert.IsTrue(response.Result != null && response.Result.ResultStatus == ResultStatus.Success);
        }
Exemplo n.º 2
0
        public async Task WhenAnyExceptionThrown_ReturnErrorResult()
        {
            //Arrage
            var messageHandler     = new FakeHttpMessageHandler(null);
            var _httpClientManager = new HttpClientManager(messageHandler);

            //Act
            var response = await _httpClientManager.GetBroadbandDeals(It.IsAny <string[]>(), It.IsAny <string>());

            // Assert
            Assert.IsTrue(response != null && response.Deals == null);
            Assert.IsTrue(response.Result != null && response.Result.ResultStatus == ResultStatus.Error);
        }
Exemplo n.º 3
0
        public async Task WhenNullInputPassed_ReturnSuccessResultWithFeeds()
        {
            //Arrage
            var data = JsonConvert.SerializeObject(TestdataGenerator.CreateFakeBroadbandResult());

            var responseMessage = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(data, System.Text.Encoding.UTF8, "application/json"),
            };
            var messageHandler     = new FakeHttpMessageHandler(responseMessage);
            var _httpClientManager = new HttpClientManager(messageHandler);

            //Act
            var response = await _httpClientManager.GetBroadbandDeals(null, null);

            // Assert
            Assert.IsTrue(response != null && response.Deals != null);
            Assert.IsTrue(response.Deals.Count > 0);
            Assert.IsTrue(response.Result != null && response.Result.ResultStatus == ResultStatus.Success);
        }