public void GivenANonExisting_PostId_DeleteStatus_ReturnsOk() { service = new TypecodeAPIServices <PostDTO>(new PostAPIRunner( new RestClient(TypecodeReader.BaseUrl), "posts/234234234", Method.DELETE)); Assert.That(service.Status, Is.EqualTo("OK")); }
public void CheckIfDeletePostReturnsOK() { service = new TypecodeAPIServices <PostDTO>(new PostAPIRunner( new RestClient(TypecodeReader.BaseUrl), "posts/1", Method.DELETE)); Assert.That(service.Status, Is.EqualTo("OK")); }
public void CheckReturnValueAreCorrect() { service = new TypecodeAPIServices <PostDTO>(new PostAPIRunner( new RestClient(TypecodeReader.BaseUrl), "posts/1")); Assert.That(service.results.id.ToString(), Is.EqualTo("1")); Assert.That(service.results.title, Is.EqualTo("sunt aut facere repellat provident occaecati excepturi optio reprehenderit")); }
public void ReturnedUserFromArrayOfUsersHasCorrectProperties_GivenName(string name) { bulkService = new TypecodeAPIServices <UsersDTO[]>(new UsersAPIRunner( new RestSharp.RestClient(TypecodeReader.BaseUrl), "users")); UsersDTO retrievedUser = UsersUtilities.GetUserIfExists(bulkService.results, name); Assert.That(retrievedUser.username, Is.EqualTo("Bret")); Assert.That(retrievedUser.phone, Is.EqualTo("1-770-736-8031 x56442")); }
public void NewAlbumIsCreated_AndReturns_Created() { _args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("title", "big sad"), new KeyValuePair <string, object>("userId", 1) }; _albumsService = new TypecodeAPIServices <AlbumsDTO>(new AlbumAPIRunner(new RestClient(TypecodeReader.BaseUrl), "/albums", Method.POST, _args)); Assert.That(_albumsService.Status, Is.EqualTo("Created")); }
public void CheckThat_TodosValues_ForUserOne_Are_Correct(int userID, int postID, string expectedTitle, bool isCompleted) { AllTodosService = new TypecodeAPIServices <TodosDTO[]>(new UsersAPIRunner(new RestClient(TypecodeReader.BaseUrl), "users/1/todos")); Assert.That(AllTodosService.results[postID - 1].userId, Is.EqualTo(userID)); Assert.That(AllTodosService.results[postID - 1].title, Is.EqualTo(expectedTitle)); Assert.That(AllTodosService.results[postID - 1].id, Is.EqualTo(postID)); Assert.That(AllTodosService.results[postID - 1].completed, Is.EqualTo(isCompleted)); }
public void AlbumTitleUpdates_IfAlbumIdIsValid() { _args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("title", "hello from the other side") }; _albumsService = new TypecodeAPIServices <AlbumsDTO>(new AlbumAPIRunner(new RestClient(TypecodeReader.BaseUrl), "/albums/1", Method.PUT, _args)); Assert.That(_albumsService.results.title, Is.EqualTo("hello from the other side")); }
public void UserIdUpdates_IfAlbumIdIsValid() { _args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("userId", 50) }; _albumsService = new TypecodeAPIServices <AlbumsDTO>(new AlbumAPIRunner(new RestClient(TypecodeReader.BaseUrl), "/albums/1", Method.PUT, _args)); Assert.That(_albumsService.results.userId, Is.EqualTo(50)); }
public void NewAlbumIsCreated_WithProvidedDetails() { _args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("title", "big sad"), new KeyValuePair <string, object>("userId", 1) }; _albumsService = new TypecodeAPIServices <AlbumsDTO>(new AlbumAPIRunner(new RestClient(TypecodeReader.BaseUrl), "/albums", Method.POST, _args)); Assert.That(_albumsService.results.userId, Is.EqualTo(1)); Assert.That(_albumsService.results.title, Is.EqualTo("big sad")); }
public void CheckThatAll_Todos_ValueTypes_AreCorrect() { AllTodosService = new TypecodeAPIServices <TodosDTO[]>(new UsersAPIRunner(new RestClient(TypecodeReader.BaseUrl), "users/1/todos")); foreach (var item in AllTodosService.results) { Assert.That(item.title.GetType(), Is.EqualTo(typeof(string))); Assert.That(item.id.GetType(), Is.EqualTo(typeof(int))); Assert.That(item.completed.GetType(), Is.EqualTo(typeof(bool))); } }
public void CreateNewPostTest() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("userId", 5) }; service = new TypecodeAPIServices <PostDTO>(new PostAPIRunner( new RestClient(TypecodeReader.BaseUrl), "posts", Method.POST, args)); Assert.That(service.results.userId, Is.EqualTo(5)); }
public void CheckNotFoundReturned_IfIDNotSpecifiedInURLOrRequestBody() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("name", "Oliver"), new KeyValuePair <string, object>("username", "Oliver123") }; service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestClient(TypecodeReader.BaseUrl), "users", Method.PUT, args)); Assert.That(service.Status, Is.EqualTo("NotFound")); }
public void CheckResultIsCreatedFromPutRequest_WithValidID() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("name", "Oliver"), new KeyValuePair <string, object>("username", "Oliver123") }; service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestClient(TypecodeReader.BaseUrl), "users/1", Method.PUT, args)); Assert.That(service.Status, Is.EqualTo("OK")); }
public void CheckCreatedUserHasCorrectName() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("name", "Oliver"), new KeyValuePair <string, object>("username", "Oliver123") }; service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestClient(TypecodeReader.BaseUrl), "users", Method.POST, args)); Assert.That(service.results.name, Is.EqualTo("Oliver")); }
public void CheckIf_PostIdReturned_is101_Given_PostId234() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("userId", 5), new KeyValuePair <string, object>("Id", 234) }; service = new TypecodeAPIServices <PostDTO>(new PostAPIRunner( new RestClient(TypecodeReader.BaseUrl), "posts", Method.POST, args)); Assert.That(service.results.id, Is.EqualTo(101)); }
public void CheckResultIsNotFoundFromPostRequest_WithInvalidID(object parameter) { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("name", "Oliver"), new KeyValuePair <string, object>("username", "Oliver123") }; service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestClient(TypecodeReader.BaseUrl), $"users{parameter}", Method.POST, args)); Assert.That(service.Status, Is.EqualTo("NotFound")); }
public void CheckReturnedUserFromPutRequest_HasCorrectChangedDetails() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("name", "Oliver"), new KeyValuePair <string, object>("username", "Oliver123") }; service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestClient(TypecodeReader.BaseUrl), "users/1", Method.PUT, args)); Assert.That(service.results.name, Is.EqualTo("Oliver")); Assert.That(service.results.username, Is.EqualTo("Oliver123")); }
public void CheckIfChangingPostId_ReturnsThePostId_Unchanged() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("id", 234234), new KeyValuePair <string, object>("title", "newTitle"), new KeyValuePair <string, object>("body", "NewBodyContent"), new KeyValuePair <string, object>("userId", 7) }; service = new TypecodeAPIServices <PostDTO>(new PostAPIRunner( new RestClient(TypecodeReader.BaseUrl), $"posts/7", Method.PUT, args)); Assert.That(service.results.userId, Is.EqualTo(7)); }
public void CreateNewPostStatusTest() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("id", 1), new KeyValuePair <string, object>("title", "newTitle"), new KeyValuePair <string, object>("body", "NewBodyContent"), new KeyValuePair <string, object>("userId", 7) }; service = new TypecodeAPIServices <PostDTO>(new PostAPIRunner( new RestClient(TypecodeReader.BaseUrl), $"posts/{args.Where(x => x.Key == "id").First().Value}", Method.PUT, args)); Assert.That(service.Status, Is.EqualTo("OK")); }
public void CheckPutRequestReturnsCorrectUser_IfCorrectOptionalIDDeclaredInRequestBody() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("id", 1), new KeyValuePair <string, object>("name", "Oliver"), new KeyValuePair <string, object>("username", "Oliver123") }; service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestClient(TypecodeReader.BaseUrl), "users/1", Method.PUT, args)); Assert.That(service.Status, Is.EqualTo("OK")); Assert.That(service.results.id, Is.EqualTo(1)); }
public void ReturnValuesHaveBeenUpdated() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("id", 1), new KeyValuePair <string, object>("title", "newTitle"), new KeyValuePair <string, object>("body", "NewBodyContent"), new KeyValuePair <string, object>("userId", 7) }; service = new TypecodeAPIServices <PostDTO>(new PostAPIRunner( new RestClient(TypecodeReader.BaseUrl), $"posts/{args.Where(x => x.Key == "id").First().Value}", Method.PUT, args)); Assert.That(service.results.title, Is.EqualTo("newTitle")); Assert.That(service.results.body, Is.EqualTo("NewBodyContent")); Assert.That(service.results.userId, Is.EqualTo(7)); }
public void CheckReturnedUserFromPutRequest_HasNoOtherFieldsChanged() { var args = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("name", "Oliver"), new KeyValuePair <string, object>("username", "Oliver123"), new KeyValuePair <string, object>("email", "*****@*****.**"), new KeyValuePair <string, object>("address", new Address { street = "Kulas Light", suite = "Apt. 556", city = "Gwenborough" }) }; service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestClient(TypecodeReader.BaseUrl), "users/1", Method.PUT, args)); Assert.That(service.results.email, Is.EqualTo("*****@*****.**")); Assert.That(service.results.address.street, Is.EqualTo("Kulas Light")); Assert.That(service.results.address.suite, Is.EqualTo("Apt. 556")); Assert.That(service.results.address.city, Is.EqualTo("Gwenborough")); }
public void CheckCorrectAddressReturnedFromGetRequest() { service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestSharp.RestClient(TypecodeReader.BaseUrl), "users/1")); Assert.That(service.results.address.street, Is.EqualTo("Kulas Light")); }
public void CheckCorrectIDReturnedFromGetRequest() { service = new TypecodeAPIServices <UsersDTO>(new UsersAPIRunner( new RestSharp.RestClient(TypecodeReader.BaseUrl), "users/1")); Assert.That(service.results.id, Is.EqualTo(1)); }
public void OneTimeSetup() { service = new TypecodeAPIServices <PostCommentsDTO[]>(new PostAPIRunner(new RestClient(TypecodeReader.BaseUrl), "posts/1/comments")); }
public void GetAllPhotos_Returns_Results_ForValidAlbumId() { _albumPhotosService = new TypecodeAPIServices <PhotosDTO[]>(new AlbumAPIRunner(new RestClient(TypecodeReader.BaseUrl), "/albums/1/photos")); Assert.That(_albumPhotosService.results.Length, Is.GreaterThan(0)); }
public void GetAllPhotos_Returns_OK_ForValidAlbumId() { _albumPhotosService = new TypecodeAPIServices <PhotosDTO[]>(new AlbumAPIRunner(new RestClient(TypecodeReader.BaseUrl), "/albums/1/photos")); Assert.That(_albumPhotosService.Status, Is.EqualTo("OK")); }
public void CheckCorrectNumberOfUsersReturnedFromGetRequest_WithNoIDSpecified() { bulkService = new TypecodeAPIServices <UsersDTO[]>(new UsersAPIRunner( new RestSharp.RestClient(TypecodeReader.BaseUrl), "users")); Assert.That(UsersUtilities.FindNumberOfUsers(bulkService.results), Is.EqualTo(10)); }
public void GetAllPhotos_Returns_NoResults_ForInvalidAlbumId() { _albumPhotosService = new TypecodeAPIServices <PhotosDTO[]>(new AlbumAPIRunner(new RestClient(TypecodeReader.BaseUrl), "/albums/1681684161986513651/photos")); Assert.That(_albumPhotosService.results.Length, Is.EqualTo(0)); }
public void CheckUserExistsInArrayOfUsers_GivenName(string name) { bulkService = new TypecodeAPIServices <UsersDTO[]>(new UsersAPIRunner( new RestSharp.RestClient(TypecodeReader.BaseUrl), "users")); Assert.That(UsersUtilities.VerifyUserExistsByName(bulkService.results, name)); }