api-client-dotnet/RetailcrmUnitTest/V5/UsersTest.cs
Alex Lushpai 72cac6d6f0
Multiversion client (#6)
* Multiversion sdk
* Remove redundant code
* More test coverage;
2017-10-30 13:51:45 +03:00

44 lines
1.5 KiB
C#

using System.Collections.Specialized;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class UsersTest
{
private readonly Client _client;
public UsersTest()
{
NameValueCollection appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void UsersStatus()
{
Response users = _client.Users();
Assert.IsTrue(users.IsSuccessfull());
Assert.IsTrue(users.GetStatusCode() == 200);
Assert.IsInstanceOfType(users, typeof(Response));
Assert.IsTrue(users.GetResponse().ContainsKey("success"));
object[] list = (object[])users.GetResponse()["users"];
var user = list[0] as Dictionary<string, object>;
Debug.Assert(user != null, nameof(user) + " != null");
int uid = int.Parse(user["id"].ToString());
Response status = _client.UsersStatus(uid, "break");
Assert.IsTrue(status.IsSuccessfull());
Assert.IsTrue(status.GetStatusCode() == 200);
Assert.IsInstanceOfType(status, typeof(Response));
Assert.IsTrue(status.GetResponse().ContainsKey("success"));
}
}
}