126 lines
4.0 KiB
C#
126 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Web.Http;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using iniPHIClientControlAPI;
|
|
using iniPHIClientControlAPI.Controllers;
|
|
using iniPHIClientControlAPI.Models;
|
|
|
|
namespace iniPHIClientControlAPI.Tests.Controllers
|
|
{
|
|
[TestClass]
|
|
public class ClientInfoControllerTest
|
|
{
|
|
//[TestMethod]
|
|
public void GetAllClientInfo()
|
|
{
|
|
// Arrange
|
|
ClientInfoController controller = new ClientInfoController();
|
|
|
|
// Act
|
|
IEnumerable<ClientInfoModel> result = controller.Get();
|
|
|
|
// Assert
|
|
Assert.IsNotNull(result);
|
|
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetClientInfoById()
|
|
{
|
|
// Arrange
|
|
ClientInfoController controller = new ClientInfoController();
|
|
|
|
// Act
|
|
ClientInfoModel result = controller.Get(Guid.NewGuid());
|
|
|
|
// Assert
|
|
Assert.IsNotNull(result);
|
|
Assert.AreEqual(1, result.Id);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void InsertClientInfo()
|
|
{
|
|
// Arrange
|
|
ClientInfoController controller = new ClientInfoController();
|
|
|
|
// Act
|
|
ClientInfoModel i = new ClientInfoModel()
|
|
{
|
|
Id = Guid.Empty,
|
|
ClientName = "test add",
|
|
InstanceUrl = "testapi",
|
|
SubscriptionGroupId = Guid.Empty,
|
|
SubscriptionEndDate = DateTime.Now.AddYears(1),
|
|
SubscriptionStartDate = DateTime.Now,
|
|
BillingFrequency = 1,
|
|
BillingType = 1,
|
|
IsActive = true,
|
|
PrimaryContactName = "Test",
|
|
PrimaryContactPhone = "555.1212",
|
|
PrimaryContactEmail = "test@test.com",
|
|
BillingContactName = "test2",
|
|
BillingContactPhone = "555.1212",
|
|
BillingContactEmail = "test2@test2.com"
|
|
};
|
|
controller.Post(i);
|
|
|
|
// Act
|
|
ClientInfoModel result = controller.Get("testapi");
|
|
|
|
// Assert
|
|
Assert.IsNotNull(result);
|
|
Assert.IsNotNull(result.InstanceUrl);
|
|
Assert.AreEqual("testapi", result.InstanceUrl);
|
|
// Assert
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
public void UpdateClientInfo()
|
|
{
|
|
// Arrange
|
|
ClientInfoController controller = new ClientInfoController();
|
|
ClientInfoModel result = controller.Get("");
|
|
// Act
|
|
DateTime subEndDate = DateTime.Now.AddYears(1);
|
|
DateTime subStartDate = DateTime.Now;
|
|
ClientInfoModel i = new ClientInfoModel()
|
|
{
|
|
Id = result.Id,
|
|
ClientName = result.ClientName,
|
|
InstanceUrl = result.InstanceUrl,
|
|
SubscriptionGroupId = result.SubscriptionGroupId,
|
|
SubscriptionEndDate = subEndDate,
|
|
SubscriptionStartDate = subStartDate,
|
|
BillingFrequency = 1,
|
|
BillingType = 1,
|
|
IsActive = true,
|
|
PrimaryContactName = "Test",
|
|
PrimaryContactPhone = "555.1212",
|
|
PrimaryContactEmail = "test@test.com",
|
|
BillingContactName = "test2",
|
|
BillingContactPhone = "555.1212",
|
|
BillingContactEmail = "test2@test2.com"
|
|
};
|
|
controller.Post(i);
|
|
|
|
// Act
|
|
ClientInfoModel result2 = controller.Get("testapi");
|
|
|
|
// Assert
|
|
Assert.IsNotNull(result2);
|
|
Assert.IsNotNull(result2.InstanceUrl);
|
|
Assert.AreEqual(result.InstanceUrl, result2.InstanceUrl);
|
|
Assert.AreEqual(subEndDate, result2.SubscriptionEndDate);
|
|
Assert.AreEqual(subStartDate, result2.SubscriptionStartDate);
|
|
// Assert
|
|
}
|
|
|
|
}
|
|
}
|