Пример #1
0
        public async Task Create_SuccessResponse_ReturnsExpectedEntity()
        {
            var id = Guid.NewGuid().ToString();

            var entity = new SampleEntity
            {
                Id   = id,
                Name = "Sample Entity"
            };

            var uri = $"{_baseUri}";

            _httpClientMock.Setup(request =>
                                  request.Method.Equals(HttpMethod.Post) &&
                                  request.RequestUri.AbsoluteUri.Equals(uri) &&
                                  request.ForType <SampleEntity>(e => e.Id.Equals(id))
                                  )
            .Returns(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(entity),
                                            Encoding.UTF8,
                                            "application/json")
            });

            var result = await _sut.Create(entity);

            Assert.That(result, Is.Not.Null);
            Assert.AreEqual(id, result.Id);
        }