Exemple #1
0
        public void ToSearchIllnessesResponse_Should_Map_Correctly()
        {
            var source = new IllnessesResponse
            {
                _embedded = new IllnessesObject
                {
                    Illnesses = new []
                    {
                        new AzureIllness {
                            Illness = new IllnessObject {
                                Id = 1
                            }
                        },
                        new AzureIllness {
                            Illness = new IllnessObject {
                                Id = 2
                            }
                        },
                        new AzureIllness {
                            Illness = new IllnessObject {
                                Id = 3
                            }
                        }
                    }
                },
                Page = new PageObject {
                    Number = 123
                }
            };

            var actual = source.ToSearchIllnessesResponse();

            actual.Data.Should().HaveSameCount(source._embedded.Illnesses);
            actual.CurrentPageIndex.Should().Be(source.Page.Number);
        }
Exemple #2
0
        public void ToSearchIllnessesResponse_Should_Handle_Null()
        {
            IllnessesResponse source = null;

            var actual = source.ToSearchIllnessesResponse();

            actual.Should().BeNull();
        }
Exemple #3
0
        public void ToSearchIllnessesResponse_Should_Handle_Null_Embedded()
        {
            var source = new IllnessesResponse();

            var actual = source.ToSearchIllnessesResponse();

            actual.Should().BeNull();
        }
Exemple #4
0
        public async void SearchIllnesses_Should_Call_Return_Correctly()
        {
            var request = new HttpRequestMessage();

            _requestProvider.CreateGetRequest(Arg.Any <string>()).Returns(request);

            var response = new IllnessesResponse
            {
                _embedded = new IllnessesObject
                {
                    Illnesses = new []
                    {
                        new AzureIllness
                        {
                            Illness = new IllnessObject {
                                Id = 1
                            }
                        },
                        new AzureIllness
                        {
                            Illness = new IllnessObject {
                                Id = 2
                            }
                        },
                        new AzureIllness
                        {
                            Illness = new IllnessObject {
                                Id = 3
                            }
                        }
                    }
                },
                Page = new PageObject
                {
                    Number        = 123,
                    Size          = 456,
                    TotalElements = 789,
                    TotalPages    = 111
                }
            };
            var expected = response.ToSearchIllnessesResponse();

            _apiClient.Send(Arg.Any <HttpRequestMessage>(), Arg.Any <Func <HttpResponseMessage, Task <IllnessesResponse> > >()).Returns(response);

            var actual = await _repository.SearchIllnesses(new SearchIllnessesRequest());

            actual.Should().BeEquivalentTo(expected);

            request.Dispose();
        }