public async Task TestThatMutationCreateAuthorsReturnsNewAuthorIdAndCorrectName() { string testName = "Mr Bond"; AuthorsResponse parsedResponse = await Server.CreateValidAuthor(testName); Assert.AreEqual(testName, parsedResponse.Data.CreateAuthor.Name, "Returned author name does not match."); Assert.AreNotEqual(Guid.Empty, parsedResponse.Data.CreateAuthor.Id, "No new author id returned."); }
public async Task TestThatQueryForAuthorsGetsListOfAuthors() { string query = @" { authors { name } }"; HttpResponseMessage response = await Server.PostGraphqlQuery(query); response.EnsureSuccessStatusCode(); string responseString = await response.Content.ReadAsStringAsync(); AuthorsResponse parsedResponse = JsonConvert.DeserializeObject <AuthorsResponse>(responseString); Assert.IsNotNull(parsedResponse.Data.Authors, "No list of authors returned."); }
public async Task TestThatQueryForNewlyCreatedAuthorReturnsThatAuthor() { string testName = "Mr Bond"; AuthorsResponse createdParsed = await Server.CreateValidAuthor(testName); string queryForNewAuthor = $@"{{author(id: ""{createdParsed.Data.CreateAuthor.Id}"") {{ ... on Author {{ id name }} }}}}" ; HttpResponseMessage response = await Server.PostGraphqlQuery(queryForNewAuthor); response.EnsureSuccessStatusCode(); string responseString = await response.Content.ReadAsStringAsync(); AuthorsResponse parsedResponse = JsonConvert.DeserializeObject <AuthorsResponse>(responseString); Assert.AreEqual(createdParsed.Data.CreateAuthor.Name, parsedResponse.Data.Author.Name, "Returned author name does not match."); Assert.AreEqual(createdParsed.Data.CreateAuthor.Id, parsedResponse.Data.Author.Id, "No new author id returned."); }