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

            var uri = $"{_baseUri}/{id}";

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

            var result = await _sut.GetById(id);

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