Example #1
0
        public void HummApiUrlSelector_Throws_On_Unknown_Country()
        {
            var selector = new HummApiUrlSelector();

            selector.Country = (HummCountry)1000;
            selector.GetUrl();
        }
Example #2
0
        public void HummApiUrlSelector_Throws_On_Unknown_Api_Version()
        {
            var selector = new HummApiUrlSelector();

            selector.ApiVersion = 1000;
            selector.GetUrl();
        }
Example #3
0
        public async Task Test_CreateKey()
        {
            var apiSelector = new HummApiUrlSelector()
            {
                Country     = HummCountry.NewZealand,
                Environment = HummEnvironment.Sandbox
            };

            var config = new HummClientConfiguration()
            {
                BaseApiUrl = apiSelector.GetUrl(),
                DeviceId   = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_NewDeviceId"),
                MerchantId = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_MerchantId"),
                PosVersion = "1.0"
            };
            var client = new HummClient(config);

            var response = await client.CreateKeyAsync(new CreateKeyRequest()
            {
                DeviceToken = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_DeviceRegistrationKey"), PosVendor = "Yort", OperatorId = "Yort"
            });

            Assert.IsNotNull(response);
            Assert.AreEqual(response.Status, RequestStates.Success);
            Assert.IsTrue(!String.IsNullOrEmpty(response.Key));
        }
Example #4
0
        public async Task CreateKey_Error()
        {
            var apiSelector = new HummApiUrlSelector()
            {
                Country     = HummCountry.Australia,
                Environment = HummEnvironment.Dummy
            };

            var config = new HummClientConfiguration()
            {
                BaseApiUrl = apiSelector.GetUrl(),
                DeviceId   = "d555",
                MerchantId = "30299999",
                PosVersion = "1.0"
            };
            var client = new HummClient(config);

            var response = await client.CreateKeyAsync(new CreateKeyRequest()
            {
                DeviceToken = "30000000", PosVendor = "Test", OperatorId = "Automated"
            });

            Assert.IsNotNull(response);
            Assert.AreEqual(RequestStates.Error, response.Status);
            Assert.AreEqual("EVAL01", response.Code);
        }
Example #5
0
        public async Task Client_Does_Not_Validate_When_Config_Disables_Validation()
        {
            var apiSelector = new HummApiUrlSelector()
            {
                Country     = HummCountry.Australia,
                Environment = HummEnvironment.Dummy
            };

            var config = new HummClientConfiguration()
            {
                BaseApiUrl           = apiSelector.GetUrl(),
                DeviceId             = "d555",
                MerchantId           = "30299999",
                PosVersion           = "1.0",
                DeviceKey            = "1234567890",
                AutoValidateRequests = false
            };
            var client = new HummClient(config);

            var request = new SendReceiptRequest()
            {
                OperatorId = "Yort",
                DeviceId   = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_DeviceId"),
                MerchantId = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_MerchantId"),
                PosVersion = "1.0",
                ClientTransactionReference = null,
                ReceiptNumber = null
            };
            var response = await client.SendReceiptAsync(request);

            Assert.IsNotNull(response);
            Assert.AreEqual(RequestStates.Error, response.Status);
        }
Example #6
0
        public void HummApiUrlSelector_Throws_On_Unknown_NZ_Api_Environment()
        {
            var selector = new HummApiUrlSelector();

            selector.Country     = HummCountry.NewZealand;
            selector.Environment = (HummEnvironment)1000;
            selector.GetUrl();
        }
Example #7
0
        public void HummApiUrlSelector_Throws_On_Unknown_AU_Api_Environment()
        {
            var selector = new HummApiUrlSelector();

            selector.Country     = HummCountry.Australia;
            selector.Environment = (HummEnvironment)1000;
            selector.GetUrl();
        }
Example #8
0
        public void HummApiUrlSelector_NewZealand_V1_Dummy_Resolves_Correctly()
        {
            var selector = new HummApiUrlSelector();

            selector.Country     = HummCountry.NewZealand;
            selector.ApiVersion  = 1;
            selector.Environment = HummEnvironment.Dummy;

            var result = selector.GetUrl();

            Assert.AreEqual(new Uri("https://integration-pos.shophumm.co.nz/webapi/v1/Test/"), result);
        }
Example #9
0
        public void HummApiUrlSelector_Australia_V1_Production_Resolves_Correctly()
        {
            var selector = new HummApiUrlSelector();

            selector.Country     = HummCountry.Australia;
            selector.ApiVersion  = 1;
            selector.Environment = HummEnvironment.Production;

            var result = selector.GetUrl();

            Assert.AreEqual(new Uri("https://pos.shophumm.com.au/webapi/v1/"), result);
        }
Example #10
0
        private static HummClient CreateTestClient()
        {
            var apiSelector = new HummApiUrlSelector()
            {
                Country     = HummCountry.NewZealand,
                Environment = HummEnvironment.Sandbox
            };

            var config = new HummClientConfiguration()
            {
                BaseApiUrl = apiSelector.GetUrl(),
                DeviceId   = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_DeviceId"),
                MerchantId = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_MerchantId"),
                PosVersion = "1.0",
                DeviceKey  = "1234567890"
            };
            var client = new HummClient(config);

            return(client);
        }
Example #11
0
        private static HummClient CreateTestClient()
        {
            var apiSelector = new HummApiUrlSelector()
            {
                Country     = HummCountry.Australia,
                Environment = HummEnvironment.Dummy
            };

            var config = new HummClientConfiguration()
            {
                BaseApiUrl = apiSelector.GetUrl(),
                DeviceId   = "d555",
                MerchantId = "30299999",
                PosVersion = "1.0",
                DeviceKey  = "1234567890"
            };
            var client = new HummClient(config);

            return(client);
        }
Example #12
0
        public void HummApiUrlSelector_Constructor_Defaults_Environment_Sandbox()
        {
            var selector = new HummApiUrlSelector();

            Assert.AreEqual(HummEnvironment.Sandbox, selector.Environment);
        }
Example #13
0
        public void HummApiUrlSelector_Constructor_Defaults_ApiVersion_1()
        {
            var selector = new HummApiUrlSelector();

            Assert.AreEqual(1M, selector.ApiVersion);
        }
Example #14
0
        public void HummApiUrlSelector_Constructor_Defaults_Country_Australia()
        {
            var selector = new HummApiUrlSelector();

            Assert.AreEqual(HummCountry.Australia, selector.Country);
        }