Пример #1
0
        public void TestInstanceWithUsernamePasswordAccesskey()
        {
            Mock <IDatastore> mockDatastore = new Mock <IDatastore>();

            WhmcsApi instance = new WhmcsApi("User", "Pass", "ABC123", "Website", mockDatastore.Object);

            Assert.NotNull(instance);
        }
Пример #2
0
        public void TestSingleProductName()
        {
            Mock <IDatastore> mockDatastore = new Mock <IDatastore>();

            mockDatastore.Setup(_productExpectation).Returns(_jsonData);

            WhmcsApi         instance      = new WhmcsApi("User", "Pass", "Website", mockDatastore.Object);
            ProductsResponse singleProduct = instance.GetProduct(1);

            Assert.Equal("Basic cPanel Shared Hosting", singleProduct.Products.Product.SingleOrDefault().Name);
        }
Пример #3
0
        public void TestGetSingleInvoice()
        {
            Mock <IDatastore> mockDatastore = new Mock <IDatastore>();

            mockDatastore.Setup(_invoiceExpectation).Returns(_jsonData);

            WhmcsApi       instance      = new WhmcsApi("User", "Pass", "Website", mockDatastore.Object);
            OrdersResponse singleInvoice = instance.GetOrders(123);

            Assert.NotNull(singleInvoice);
        }
Пример #4
0
        public void TestGetAllProducts()
        {
            Mock <IDatastore> mockDatastore = new Mock <IDatastore>();

            mockDatastore.Setup(_productExpectation).Returns(_jsonData);

            WhmcsApi         instance = new WhmcsApi("User", "Pass", "Website", mockDatastore.Object);
            ProductsResponse test     = instance.GetProducts();

            Assert.NotNull(test);
        }
Пример #5
0
        public void TestGetStats()
        {
            Mock <IDatastore> mockDatastore = new Mock <IDatastore>();

            mockDatastore.Setup(_statsExpectation).Returns(_jsonData);

            WhmcsApi      instance = new WhmcsApi("User", "Pass", "Website", mockDatastore.Object);
            StatsResponse stats    = instance.GetStats();

            Assert.Equal("123", stats.OrdersYesterdayPending);
        }
Пример #6
0
        public void TestSingleInvoiceItemAmount()
        {
            Mock <IDatastore> mockDatastore = new Mock <IDatastore>();

            mockDatastore.Setup(_invoiceExpectation).Returns(_jsonData);

            WhmcsApi        instance      = new WhmcsApi("User", "Pass", "Website", mockDatastore.Object);
            InvoiceResponse singleInvoice = instance.GetInvoice(218);

            Assert.Equal("7.50", singleInvoice.Items.Item.SingleOrDefault().Amount);
        }
Пример #7
0
        public string ExecuteAction(WhmcsServiceObject data)
        {
            string pass = new Security.Password().HashPassword(data.Password);
            NameValueCollection apidata = data.PostData;

            apidata.Add("action", data.Action);
            apidata.Add("username", data.Username);
            apidata.Add("password", pass);
            apidata.Add("responsetype", "json");
            if (!string.IsNullOrEmpty(data.AccessKey))
            {
                apidata.Add("accesskey", data.AccessKey);
            }
            string result = new WhmcsApi().CallWhmcsApi(data.WhmcsApiUrl, apidata);

            return(result);
        }
Пример #8
0
 public void TestInitialize()
 {
     whmcsApi = new WhmcsApi("X", "Y", "Z", true, new TestableDataStore());
 }
Пример #9
0
 public void TestWrongConnectionValues()
 {
     whmcsApi = new WhmcsApi("Username", "Password", "Domain.tld", true, new DataStore());
     whmcsApi.GetProducts();
 }
Пример #10
0
 static void Main()
 {
     var whmcs = new WhmcsApi("Username", "Password", "Domain", true, new DataStore());
 }