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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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 }); }
public void should_recall_values_that_previously_remembered() { actor.Remember(key, value); actor.Should(See.That(Remember.ValueOf <long>(key))).IsEqualTo(value); }