Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Considering your comment about in-memory database change you are planning for, following are some examples of how you could do write tests in your scenario:</p> <pre><code> PeopleController people = new PeopleController(); // mismatched person Id returns BadRequest Person person = new Person(); person.Id = 11; person.Name = "John updated"; IHttpActionResult result = people.PutPerson(10, person).Result; Assert.IsInstanceOfType(result, typeof(BadRequestResult)); // --------------------------------------------------- // non-existing person Person person = new Person(); person.Id = 1000; person.Name = "John updated"; IHttpActionResult result = people.PutPerson(1000, person).Result; Assert.IsInstanceOfType(result, typeof(NotFoundResult)); // -------------------------------------------------------- //successful update of person information and its verification Person person = new Person(); person.Id = 10; person.Name = "John updated"; IHttpActionResult result = people.PutPerson(10, person).Result; StatusCodeResult statusCodeResult = result as StatusCodeResult; Assert.IsNotNull(statusCodeResult); Assert.AreEqual&lt;HttpStatusCode&gt;(HttpStatusCode.NoContent, statusCodeResult.StatusCode); //retrieve the person to see if the update happened successfully IHttpActionResult getPersonResult = people.GetPerson(10).Result; OkNegotiatedContentResult&lt;Person&gt; negotiatedResult = getPersonResult as OkNegotiatedContentResult&lt;Person&gt;; Assert.IsNotNull(negotiatedResult); Assert.AreEqual&lt;string&gt;(person.Name, negotiatedResult.Content.Name); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload