mirror of
https://github.com/retailcrm/api-client-dotnet.git
synced 2024-11-29 00:06:10 +03:00
8ef01ecfb5
* update test to use env variables
349 lines
12 KiB
C#
349 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Retailcrm;
|
|
using Retailcrm.Versions.V3;
|
|
|
|
namespace RetailcrmUnitTest.V3
|
|
{
|
|
[TestClass]
|
|
public class ReferencesTest
|
|
{
|
|
private readonly Client _client;
|
|
|
|
public ReferencesTest()
|
|
{
|
|
_client = new Client(
|
|
Environment.GetEnvironmentVariable("RETAILCRM_URL"),
|
|
Environment.GetEnvironmentVariable("RETAILCRM_KEY")
|
|
);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Countries()
|
|
{
|
|
Response response = _client.Countries();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void DeliveryServices()
|
|
{
|
|
Response response = _client.DeliveryServices();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void DeliveryTypes()
|
|
{
|
|
Response response = _client.DeliveryTypes();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OrderMethods()
|
|
{
|
|
Response response = _client.OrderMethods();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OrderTypes()
|
|
{
|
|
Response response = _client.OrderTypes();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PaymentStatuses()
|
|
{
|
|
Response response = _client.PaymentStatuses();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PaymentTypes()
|
|
{
|
|
Response response = _client.PaymentTypes();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ProductStatuses()
|
|
{
|
|
Response response = _client.ProductStatuses();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Sites()
|
|
{
|
|
Response response = _client.Sites();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void StatusGroups()
|
|
{
|
|
Response response = _client.StatusGroups();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Statuses()
|
|
{
|
|
Response response = _client.Statuses();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Stores()
|
|
{
|
|
Response response = _client.Stores();
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void DeliveryServicesEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.DeliveryServicesEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestDeliveryService-{guid}" }
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void DeliveryTypesEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.DeliveryTypesEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestDeliveryType-{guid}" },
|
|
{ "defaultCost", 300 },
|
|
{ "defaultNetCost", 250}
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OrderMethodsEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.OrderMethodsEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestOrderMethod-{guid}" }
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void OrderTypesEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.OrderTypesEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestOrderType-{guid}" }
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PaymentStatusesEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.PaymentStatusesEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestPaymentStatus-{guid}" }
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PaymentTypesEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.PaymentTypesEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestPaymentType-{guid}" }
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ProductStatusesEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.ProductStatusesEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestProductStatus-{guid}" }
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SitesEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.SitesEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestProductStatus-{guid}" },
|
|
{ "url", $"http://{guid}.example.org" }
|
|
}
|
|
);
|
|
|
|
Assert.IsFalse(response.IsSuccessfull());
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void StatusesEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.StatusesEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestProductStatus-{guid}" },
|
|
{ "ordering", 40},
|
|
{ "group", "cancel"}
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void StoresEdit()
|
|
{
|
|
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
|
|
|
|
Response response = _client.StoresEdit(
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "code", guid},
|
|
{ "name", $"TestProductStatus-{guid}" },
|
|
{ "type", "store-type-warehouse"}
|
|
}
|
|
);
|
|
|
|
Assert.IsTrue(response.IsSuccessfull());
|
|
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
|
|
Assert.IsInstanceOfType(response, typeof(Response));
|
|
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
|
}
|
|
}
|
|
} |