public async Task Login_CreatesNewAuthKey(UserSyncanoClient client) { //when var result = await client.Login(TestData.UserName, TestData.UserPassword); //then result.ShouldNotBeNull(); }
public async Task Login_WithNullPassword_CreatesNewAuthKey(UserSyncanoClient client) { try { await client.Login("userName", null); throw new Exception("Login should throw an exception."); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }
public async Task Login_WithInvalidPasswordOverHttp_ThrowsException() { //given var httpClient = new UserSyncanoClient(new SyncanoHttpClient(TestData.InstanceName, TestData.UserApiKey)); try { //when await httpClient.Login(TestData.UserName, "abcde"); throw new Exception("Login should throw an exception."); } catch (Exception e) { //then e.ShouldBeType<SyncanoException>(); } }
public async Task GetOne_GetsUserObject_OverHttp() { //given var httpClient = new UserSyncanoClient(new SyncanoHttpClient(TestData.InstanceName, TestData.UserApiKey)); await httpClient.Login(TestData.UserName, TestData.UserPassword); //when var result = await httpClient.GetOne(userName:TestData.UserName); //then result.ShouldNotBeNull(); }
public async Task Get_WithNullCollectionIdAndCollectionKey_ThrowsException(UserSyncanoClient client) { //given var request = new UserQueryRequest(); request.ProjectId = TestData.ProjectId; try { //when await client.Get(request); throw new Exception("Get should throw an exception."); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }
public async Task Get_WithInvalidCollectionId_ThrowsException(UserSyncanoClient client) { //given var request = new UserQueryRequest(); request.ProjectId = TestData.ProjectId; request.CollectionId = "abcde"; try { //when await client.Get(request); throw new Exception("Get should throw an exception."); } catch (Exception e) { //then e.ShouldBeType<SyncanoException>(); } }
public async Task Count_WithFolderListName_GetsCountOfUsers(UserSyncanoClient client) { //given var dataRequest = new DataObjectDefinitionRequest(); dataRequest.ProjectId = TestData.ProjectId; dataRequest.CollectionId = TestData.CollectionId; dataRequest.Folder = TestData.FolderName; await _dataClient.New(dataRequest); var request = new UserQueryRequest(); request.ProjectId = TestData.ProjectId; request.CollectionId = TestData.CollectionId; request.Folders = new List<string> { TestData.FolderName }; //when var result = await client.Count(request); //then result.ShouldEqual(1); //cleanup var deleteRequest = new DataObjectSimpleQueryRequest(); deleteRequest.ProjectId = TestData.ProjectId; deleteRequest.CollectionId = TestData.CollectionId; await _dataClient.Delete(deleteRequest); }
public async Task Delete_ByUserName_WithAvatar_CreatesNewUserObject(UserSyncanoClient client) { //given string name = "newUserName" + Guid.NewGuid().GetHashCode(); const string password = "******"; var avatar = TestData.ImageToBase64("smallSampleImage.png"); var user = await client.New(name, password, avatar: avatar); //cleanup var result = await client.Delete(userName: user.Name); //then result.ShouldBeTrue(); }
public async Task Update_DeleteAvatar_UpdatesUserObject(UserSyncanoClient client) { //given string name = "newUserName" + Guid.NewGuid().GetHashCode(); const string password = "******"; var user = await client.New(name, password, avatar: TestData.ImageToBase64("smallSampleImage.png")); //when var updatedUser = await client.Update(user.Id, avatar: "", currentPassword: password); //then updatedUser.ShouldNotBeNull(); updatedUser.Id.ShouldEqual(user.Id); updatedUser.Avatar.ShouldBeNull(); //cleanup await client.Delete(user.Id); }
public async Task Count_WithPendingState_GetsCountOfUsers(UserSyncanoClient client) { //given var dataRequest = new DataObjectDefinitionRequest(); dataRequest.ProjectId = TestData.ProjectId; dataRequest.CollectionId = TestData.CollectionId; dataRequest.State = DataObjectState.Pending; await _dataClient.New(dataRequest); var request = new UserQueryRequest(); request.ProjectId = TestData.ProjectId; request.CollectionId = TestData.CollectionId; request.State = DataObjectState.Pending; //when var result = await client.Count(request); //then result.ShouldEqual(1); //cleanup var deleteRequest = new DataObjectSimpleQueryRequest(); deleteRequest.ProjectId = TestData.ProjectId; deleteRequest.CollectionId = TestData.CollectionId; await _dataClient.Delete(deleteRequest); }
public async Task GetAll_WithLimit_GetsListOfUsers(UserSyncanoClient client) { //when var result = await client.GetAll(limit: 1); //then result.ShouldNotBeNull(); result.ShouldNotBeEmpty(); result.Count.ShouldEqual(1); }
public async Task GetOne_ByUserName_GetsUserObject(UserSyncanoClient client) { //when var result = await client.GetOne(userName: TestData.UserName); //then result.ShouldNotBeNull(); result.Id.ShouldEqual(TestData.UserId); result.Name.ShouldEqual(TestData.UserName); }
public async Task New_WithNullName_ThrowsException(UserSyncanoClient client) { try { //when await client.New(null); throw new Exception("New should throw an exception."); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }
public async Task New_WithAvatar_CreatesNewUserObject(UserSyncanoClient client) { //given string name = "newUserName" + Guid.NewGuid().GetHashCode(); string avatar = TestData.ImageToBase64("smallSampleImage.png"); //when var user = await client.New(name, avatar: avatar); //then user.ShouldNotBeNull(); user.Name.ShouldEqual(name); user.Avatar.ShouldNotBeNull(); //cleanup await client.Delete(user.Id); }
public async Task New_WithPassword_CreatesNewUserObject(UserSyncanoClient client) { //given string name = "newUserName" + Guid.NewGuid().GetHashCode(); const string password = "******"; //when var user = await client.New(name, password); //then user.ShouldNotBeNull(); user.Name.ShouldEqual(name); //cleanup await client.Delete(user.Id); }
public async Task New_WithNick_CreatesNewUserObject(UserSyncanoClient client) { //given string name = "newUserName" + Guid.NewGuid().GetHashCode(); const string nick = "newUserNick"; //when var user = await client.New(name, nick: nick); //then user.ShouldNotBeNull(); user.Name.ShouldEqual(name); user.Nick.ShouldEqual(nick); //cleanup await client.Delete(user.Id); }
public async Task Delete_WithNullUserIdAndName_ThrowsException(UserSyncanoClient client) { try { //when await client.Delete(); throw new Exception("Delete should throw an exception."); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }
public async Task Update_NewPassword_UpdatesUserObject(UserSyncanoClient client) { //given string name = "newUserName" + Guid.NewGuid().GetHashCode(); const string password = "******"; const string newPassword = "******"; var user = await client.New(name, password); //when var updatedUser = await client.Update(user.Id, newPassword: newPassword, currentPassword: password); //then updatedUser.ShouldNotBeNull(); updatedUser.Id.ShouldEqual(user.Id); //cleanup await client.Delete(user.Id); }
public async Task GetAll_WithSinceId_GetsListOfUsers(UserSyncanoClient client) { //when var result = await client.GetAll(TestData.OldUserId); //then result.ShouldNotBeNull(); result.ShouldNotBeEmpty(); result.Count.ShouldEqual(1); }
public async Task Update_NoUserId_UpdatesUserObject_OverHttp() { //given var httpClient = new UserSyncanoClient(new SyncanoHttpClient(TestData.InstanceName, TestData.UserApiKey)); await httpClient.Login(TestData.UserName, TestData.UserPassword); //when var user = await httpClient.Update(currentPassword: TestData.UserPassword); //then user.Name.ShouldEqual(TestData.UserName); }
public async Task GetAll_WithTooBigLimit_ThrowsException(UserSyncanoClient client) { try { //when await client.GetAll(limit: UserSyncanoClient.MaxLimit + 1); throw new Exception("GetAll should throw an exception."); } catch (Exception e) { //then e.ShouldBeType<ArgumentException>(); } }
public async Task Login_WithInvalidName_CreatesNewAuthKey(UserSyncanoClient client) { try { await client.Login("abcde", TestData.UserPassword); throw new Exception("Login should throw an exception."); } catch (Exception e) { //then e.ShouldBeType<SyncanoException>(); } }
public async Task Get_WithTextContentFilter_GetsListOfUsers(UserSyncanoClient client) { //given var dataRequest = new DataObjectDefinitionRequest(); dataRequest.ProjectId = TestData.ProjectId; dataRequest.CollectionId = TestData.CollectionId; dataRequest.Text = "sample text content"; await _dataClient.New(dataRequest); var request = new UserQueryRequest(); request.ProjectId = TestData.ProjectId; request.CollectionId = TestData.CollectionId; request.Filter = DataObjectContentFilter.Text; //when var result = await client.Get(request); //then result.ShouldNotBeNull(); result.Count.ShouldEqual(1); //cleanup var deleteRequest = new DataObjectSimpleQueryRequest(); deleteRequest.ProjectId = TestData.ProjectId; deleteRequest.CollectionId = TestData.CollectionId; await _dataClient.Delete(deleteRequest); }
public async Task Count_WithImageContentFilter_GetsCountOfUsers(UserSyncanoClient client) { //given var dataRequest = new DataObjectDefinitionRequest(); dataRequest.ProjectId = TestData.ProjectId; dataRequest.CollectionId = TestData.CollectionId; dataRequest.ImageBase64 = TestData.ImageToBase64("smallSampleImage.png"); await _dataClient.New(dataRequest); var request = new UserQueryRequest(); request.ProjectId = TestData.ProjectId; request.CollectionId = TestData.CollectionId; request.Filter = DataObjectContentFilter.Image; //when var result = await client.Count(request); //then result.ShouldEqual(1); //cleanup var deleteRequest = new DataObjectSimpleQueryRequest(); deleteRequest.ProjectId = TestData.ProjectId; deleteRequest.CollectionId = TestData.CollectionId; await _dataClient.Delete(deleteRequest); }
public async Task Delete_ByUserName_WithPassword_DeletesUserObject(UserSyncanoClient client) { //given string name = "newUserName" + Guid.NewGuid().GetHashCode(); const string password = "******"; var user = await client.New(name, password); //when var result = await client.Delete(userName: user.Name); //then result.ShouldBeTrue(); }