This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK-8 fix search by user emails (#21)
* fix search by user emails, add integration test
- Loading branch information
1 parent
efd9e25
commit ce0195d
Showing
6 changed files
with
107 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
apiClientDotNetTest/Resources/template.integration.parameters.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Please use this template to create the integration parameters configuration file | ||
// The integration tests needs a file named integration.parameters.json in the Resources folder | ||
{ | ||
// Parameters common for all tests | ||
"test_username": "user name", | ||
"test_useremail": "user email", | ||
"test_displayname": "account display name", | ||
"test_room_name": "name of a room", | ||
// Parameters related to a specific test | ||
"UserClientIntegrationTest": { | ||
"test_email_addresses": "comma separated string of email addresses", | ||
"test_search_user_query": "search by some query like name" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using apiClientDotNet; | ||
using apiClientDotNet.Authentication; | ||
using apiClientDotNet.Clients; | ||
using apiClientDotNet.Models; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace apiClientDotNetTest | ||
{ | ||
[TestClass] | ||
public class UserClientIntegrationTest | ||
{ | ||
private static SymBotClient symBotClient; | ||
private static IConfigurationRoot config; | ||
|
||
[ClassInitialize] | ||
public static void Init(TestContext context) | ||
{ | ||
// Load integration test settings | ||
var integrationConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "integration.parameters.json"); | ||
config = new ConfigurationBuilder().AddJsonFile(integrationConfigPath).Build(); | ||
|
||
// Create SymBotClient | ||
var symConfig = new SymConfig(); | ||
var symConfigLoader = new SymConfigLoader(); | ||
var configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "config.json"); | ||
symConfig = symConfigLoader.loadFromFile(configPath); | ||
var botAuth = new SymBotRSAAuth(symConfig); | ||
botAuth.authenticate(); | ||
symBotClient = SymBotClient.initBot(symConfig, botAuth); | ||
} | ||
|
||
[TestMethod] | ||
public void GetUsersV3_forGivenListOfEmails_correctlyReturnListOfUsers() | ||
{ | ||
var emails = config.GetSection(this.GetType().Name).GetSection("test_email_addresses").Value; | ||
var emailList = emails.Split(","); | ||
var sut = new UserClient(symBotClient); | ||
|
||
List<UserInfo> listUserInfo = sut.getUsersV3(new List<string>(emailList), null, false); | ||
|
||
Assert.IsNotNull(listUserInfo); | ||
Assert.AreEqual(3, listUserInfo.Count); | ||
Assert.IsFalse(String.IsNullOrEmpty(listUserInfo[0].displayName)); | ||
Assert.IsFalse(String.IsNullOrEmpty(listUserInfo[0].username)); | ||
|
||
Assert.IsFalse(String.IsNullOrEmpty(listUserInfo[1].displayName)); | ||
Assert.IsFalse(String.IsNullOrEmpty(listUserInfo[1].username)); | ||
|
||
Assert.IsFalse(String.IsNullOrEmpty(listUserInfo[2].displayName)); | ||
Assert.IsFalse(String.IsNullOrEmpty(listUserInfo[2].username)); | ||
} | ||
|
||
[TestMethod] | ||
public void SearchUsers_forGivenSearchQuery_correctlyReturnsListOfUsers() | ||
{ | ||
var query = config.GetSection(this.GetType().Name).GetSection("test_search_user_query").Value; | ||
var sut = new UserClient(symBotClient); | ||
|
||
UserSearchResult searchUsers = sut.searchUsers(query, false, 0, 10, null); | ||
|
||
Assert.IsNotNull(searchUsers); | ||
Assert.IsTrue(searchUsers.users.Count >= 1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters