mirror of
https://github.com/retailcrm/api-client-dotnet.git
synced 2024-11-27 07:16:05 +03:00
8ef01ecfb5
* update test to use env variables
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System;
|
|
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()
|
|
{
|
|
_client = new Client(
|
|
Environment.GetEnvironmentVariable("RETAILCRM_URL"),
|
|
Environment.GetEnvironmentVariable("RETAILCRM_KEY")
|
|
);
|
|
}
|
|
|
|
[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"));
|
|
}
|
|
}
|
|
}
|