コード例 #1
0
 public LoginWorkflow(IWebDriver driver, ExtentTest test) : base(driver, test)
 {
     login          = new Login(Driver);
     hummClient     = new HummClient();
     signUpWorkflow = new SignUpWorkflow(Driver, extentTest);
     signUp         = new SignUp(Driver);
 }
コード例 #2
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));
        }
コード例 #3
0
        public async Task HummClient_Throws_On_NonSuccess_Response()
        {
            var handler = new MockHttpHandler
                          (
                (clientRequest) =>
            {
                return(Task.FromResult(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest)));
            }
                          );

            var config = new HummClientConfiguration()
            {
                BaseApiUrl = new Uri("https://integration-pos.shophumm.com.au/webapi/v1/Test/"),
                MerchantId = "30299999",
                DeviceId   = "d555",
                PosVersion = "1.0",
                DeviceKey  = "1234567890",
                HttpClient = new HttpClient(handler)
            };

            var client = new HummClient(config);

            var request = new InviteRequest()
            {
                MobileNumber = "0400000", PurchaseAmount = 10.01M, OperatorId = "Automated"
            };

            _ = await client.InviteAsync(request);
        }
コード例 #4
0
        public async Task HummClient_Sets_Default_UserAgent()
        {
            string sentUserAgent = null;

            var handler = new MockHttpHandler
                          (
                (clientRequest) =>
            {
                sentUserAgent = clientRequest.Headers.UserAgent.ToString();
                return(GetSuccessfulInviteResponse());
            }
                          );

            var config = new HummClientConfiguration()
            {
                BaseApiUrl = new Uri("https://integration-pos.shophumm.com.au/webapi/v1/Test/"),
                MerchantId = "30299999",
                DeviceId   = "d555",
                PosVersion = "1.0",
                DeviceKey  = "1234567890",
                HttpClient = new HttpClient(handler)
            };

            var client = new HummClient(config);

            var request = new InviteRequest()
            {
                MobileNumber = "0400000", PurchaseAmount = 10.01M, OperatorId = "Automated"
            };
            var response = await client.InviteAsync(request);

            Assert.AreEqual("Yort.Humm.Instore/" + typeof(HummClientConfiguration).Assembly.GetName().Version.ToString(), sentUserAgent);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
        public void Constructor_Accepts_Null_DeviceKey()
        {
            var config = new HummClientConfiguration()
            {
                BaseApiUrl = new Uri("https://integration-pos.shophumm.com.au/webapi/v1/"),
                DeviceKey  = null,
                DeviceId   = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_DeviceId"),
                MerchantId = Environment.GetEnvironmentVariable("Humm_Test_Sandbox_MerchantId"),
                PosVersion = "1.0"
            };

            _ = new HummClient(config);
        }
コード例 #8
0
        private static HummClient CreateMockedClient(MockHttpHandler handler)
        {
            var config = new HummClientConfiguration()
            {
                BaseApiUrl              = new Uri("https://integration-pos.shophumm.com.au/webapi/v1/Test/"),
                UserAgentProductName    = "TestPOS",
                UserAgentProductVersion = "1.5",
                MerchantId              = "30299999",
                DeviceId   = "d555",
                PosVersion = "1.0",
                DeviceKey  = "1234567890",
                HttpClient = new HttpClient(handler)
            };

            var client = new HummClient(config);

            return(client);
        }
コード例 #9
0
        public async Task HummClient_Exception_On_NonSuccess_Includes_Response_Content()
        {
            var handler = new MockHttpHandler
                          (
                (clientRequest) =>
            {
                return(Task.FromResult(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest)
                {
                    Content = new StringContent("Unrecognised fields in request")
                }));
            }
                          );

            var config = new HummClientConfiguration()
            {
                BaseApiUrl = new Uri("https://integration-pos.shophumm.com.au/webapi/v1/Test/"),
                MerchantId = "30299999",
                DeviceId   = "d555",
                PosVersion = "1.0",
                DeviceKey  = "1234567890",
                HttpClient = new HttpClient(handler)
            };

            var client = new HummClient(config);

            string responseContent = null;
            var    request         = new InviteRequest()
            {
                MobileNumber = "0400000", PurchaseAmount = 10.01M, OperatorId = "Automated"
            };

            try
            {
                _ = await client.InviteAsync(request);
            }
            catch (HttpRequestException ex)
            {
                responseContent = (string)ex.Data["ResponseContent"];
            }

            Assert.AreEqual("Unrecognised fields in request", responseContent);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #12
0
 public SignUpWorkflow(IWebDriver driver, ExtentTest test) : base(driver, test)
 {
     signUP = new SignUp(Driver);
     hummClient = new HummClient();
     login = new Login(Driver);
 }
コード例 #13
0
        public void Constructor_Throws_On_Null_Config_BaseUrl()
        {
            var config = new HummClientConfiguration();

            _ = new HummClient(config);
        }
コード例 #14
0
 public void Constructor_Throws_On_Null_Config()
 {
     _ = new HummClient(null);
 }