Beispiel #1
0
        public async Task CreateImposter_SendsRequest_ImpostersResource()
        {
            var expectedResource = "imposters";

            var response = GetResponse(HttpStatusCode.Created);

            _mockClient.Setup(x => x.PostAsync(expectedResource, It.IsAny <HttpContent>()))
            .ReturnsAsync(response);

            await _proxy.CreateImposterAsync(new HttpImposter(123, null)).ConfigureAwait(false);

            _mockClient.Verify(x => x.PostAsync(expectedResource, It.IsAny <HttpContent>()), Times.Once);
        }
Beispiel #2
0
        public async Task CreateImposter_SendsRequest()
        {
            const string expectedResource = "imposters";

            var imposter = new HttpImposter(123, null);

            var response = GetResponse(HttpStatusCode.Created);

            HttpContent content = null;

            _mockClient.Setup(x => x.PostAsync(expectedResource, It.IsAny <HttpContent>(), default))
            .ReturnsAsync(response)
            .Callback <string, HttpContent, CancellationToken>((res, cont, _) => content = cont);

            await _proxy.CreateImposterAsync(imposter).ConfigureAwait(false);

            var json = await content.ReadAsStringAsync();

            var serializedImposter = JsonConvert.DeserializeObject <HttpImposter>(json);

            Assert.AreEqual(imposter.Port, serializedImposter.Port);
        }