Пример #1
0
        public void UrlInvalidShouldThrowException()
        {
            var         adapter = new AzurePeopleAdapter(new RestClient("http://test.net/people.json"));
            Func <Task> func    = async() => await adapter.GetPetOwners();

            func.ShouldThrow <InvalidOperationException>();
        }
Пример #2
0
        public async Task ShouldGetPeopleAndModelShouldBeValid()
        {
            var data = await _adapter.GetPetOwners();

            data.Should().NotBeNullOrEmpty();

            var bob = data.FirstOrDefault(x => x.Name == "Bob");

            ValidateBob(bob);
        }
Пример #3
0
        public async Task ShouldReturnData()
        {
            var requestData = Fixture.CreateMany <Person>().ToList();

            IRestResponse <List <Person> > response = new RestResponse <List <Person> >
            {
                StatusCode     = System.Net.HttpStatusCode.OK,
                ResponseStatus = ResponseStatus.Completed,
                Data           = requestData
            };

            _mockRestClient.Setup(x => x.ExecuteGetTaskAsync <List <Person> >(It.IsNotNull <IRestRequest>()))
            .ReturnsAsync(response);

            var data = await _adapter.GetPetOwners();

            data.Should().NotBeNull();
            data.Should().BeEquivalentTo(requestData);
        }