Ejemplo n.º 1
0
        public void should_return_last_http_status_code()
        {
            this.SetupResponse(new HttpResponseBuilder().WithHttpStatusCode(HttpStatusCode.NotFound).Build());

            Actor.AttemptsTo(Get.ResourceAt("api/resource"));

            Actor.Should(See.That(LastResponse.StatusCode())).IsEqualTo(HttpStatusCode.NotFound);
        }
Ejemplo n.º 2
0
        public void should_return_nfluent_check_based_on_underlying_question_result()
        {
            const long expectedAnswer = 10;
            var        question       = new StubQuestion <long>(expectedAnswer);
            var        jack           = Actor.Named(Names.Jack);

            jack.Should(See.That(question)).IsEqualTo(expectedAnswer);
        }
Ejemplo n.º 3
0
        public void should_return_last_http_headers_by_key()
        {
            var locationHeaderValue = "http://localhost:5000/api/resource/1";

            SetupResponse(new HttpResponseBuilder().WithHeader(HttpHeaders.Location, locationHeaderValue).Build());

            Actor.AttemptsTo(Post.DataAsJson(new { }).To("api/resource"));

            Actor.Should(See.That(LastResponse.Header(HttpHeaders.Location))).IsEqualTo(locationHeaderValue);
        }
Ejemplo n.º 4
0
        public void Fetch_user_by_id()
        {
            var jack             = Actor.Named("Jack").WhoCan(CallAnApi.At("https://reqres.in"));
            var expectedResponse = new GetUserByIdResponse(id: 2, name: "fuchsia rose");

            jack.AttemptsTo(FetchUserById(2));

            jack.Should(See.That(LastResponse.Content <GetUserByIdResponse>()))
            .Considering().All.Properties.HasFieldsWithSameValues(expectedResponse);
            jack.Should(See.That(LastResponse.StatusCode())).IsEqualTo(HttpStatusCode.OK);
        }
Ejemplo n.º 5
0
        public void Delete_an_user()
        {
            var jack = Actor.Named("Jack").WhoCan(CallAnApi.At("https://reqres.in"));
            var user = new User {
                Name = "Sarah", Job = "Software Architect"
            };

            jack.AttemptsTo(DeleteAn(user));

            jack.Should(See.That(LastResponse.Content <object>())).IsNull();
            jack.Should(See.That(LastResponse.StatusCode())).IsEqualTo(HttpStatusCode.NoContent);
        }
Ejemplo n.º 6
0
        public void should_return_last_http_content()
        {
            var response = "{firstname:'foo', lastname:'bar'}";

            this.SetupResponse(new HttpResponseBuilder().WithContent(response).Build());
            var expectedCustomer = new Customer {
                Firstname = "foo", Lastname = "bar"
            };

            Actor.AttemptsTo(Get.ResourceAt("api/resource"));

            Actor.Should(See.That(LastResponse.Content <Customer>())).HasPropertiesWithSameValues(expectedCustomer);
        }
Ejemplo n.º 7
0
        public void Modify_part_of_an_user()
        {
            var jack = Actor.Named("Jack").WhoCan(CallAnApi.At("https://reqres.in"));
            var user = new User {
                Name = "Sarah", Job = "Software Architect"
            };

            jack.AttemptsTo(ModifyPartOf(user));

            jack.Should(See.That(LastResponse.Content <ModifyUserResponse>()))
            .Considering().All.Properties.HasFieldsWithSameValues(user);
            jack.Should(See.That(LastResponse.StatusCode())).IsEqualTo(HttpStatusCode.OK);
        }
Ejemplo n.º 8
0
        public void should_post_a_person_to_api()
        {
            var jack   = Actor.Named("Jack").WhoCan(CallAnApi.At(_fixture.Host.BaseUrl));
            var person = new CreatePerson {
                Firstname = "Sarah", Lastname = "Ohara"
            };

            jack.AttemptsTo(Post.DataAsJson(person).To("api/People"));
            var resourceLocation = jack.AsksFor(LastResponse.Header(HttpHeaders.Location));

            jack.AttemptsTo(Get.ResourceAt(resourceLocation));

            jack.Should(See.That(LastResponse.Content <Person>()))
            .Considering().All.Properties.HasFieldsWithSameValues(person);
        }
Ejemplo n.º 9
0
        public void should_return_all_last_http_headers()
        {
            var locationHeaderValue = "http://localhost:5000/api/resource/1";
            var originValue         = "*";

            SetupResponse(new HttpResponseBuilder()
                          .WithHeader(HttpHeaders.Location, locationHeaderValue)
                          .WithHeader(HttpHeaders.AccessControlAllowOrigin, originValue)
                          .Build());

            Actor.AttemptsTo(Get.ResourceAt("api/resource"));

            Actor.Should(See.That(LastResponse.Headers()))
            .ContainsPair(HttpHeaders.Location, new List <string> {
                locationHeaderValue
            })
            .And.ContainsPair(HttpHeaders.AccessControlAllowOrigin, new List <string> {
                originValue
            });
        }
Ejemplo n.º 10
0
        public void should_recall_values_that_previously_remembered()
        {
            actor.Remember(key, value);

            actor.Should(See.That(Remember.ValueOf <long>(key))).IsEqualTo(value);
        }