public async Task TestGetTemplatesWithInvalidApiKeyAsync()
        {
            Trace.WriteLine(String.Format("GET /templates with invalid API Key: {0}", INVALID_API_KEY));

            // Set the API Key to an invalid key and save the original key
            var originalApiKey = SendwithusClient.ApiKey;

            SendwithusClient.ApiKey = INVALID_API_KEY;

            // Make the API call
            try
            {
                var templates = await Template.GetTemplatesAsync();
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 403 Forbidden
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.Forbidden);
            }
            finally
            {
                // Set the API Key back to its original value
                SendwithusClient.ApiKey = originalApiKey;
            }
        }
        public async Task TestGetTemplateByIdAndLocaleInvalidLocaleAsync()
        {
            // Make the API call
            Trace.WriteLine(String.Format("GET /templates/{0}/locales/{1} with invalid locale", DEFAULT_TEMPLATE_ID, INVALID_LOCALE));
            try
            {
                var template = await Template.GetTemplateAsync(DEFAULT_TEMPLATE_ID, INVALID_LOCALE);

                Assert.Fail("Failed to throw exception");
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 400 Bad Request
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.BadRequest);
            }
        }
示例#3
0
        public async Task TestGetCustomerWithInvalidEmailAddressAsync()
        {
            // Make the API call
            Trace.WriteLine(String.Format("GET /customers/{0}", INVALID_CUSTOMER_EMAIL_ADDRESS));
            try
            {
                var customerResponse = await Customer.GetCustomerAsync(INVALID_CUSTOMER_EMAIL_ADDRESS);

                Assert.Fail("Failed to throw exception");
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 400 Bad Request
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.BadRequest);
            }
        }
示例#4
0
        public async Task TestGetSnippetWithInvalidIDAsync()
        {
            Trace.WriteLine("GET /snippets with an invalid ID");

            // Make the API call
            try
            {
                var snippet = await Snippet.GetSnippetAsync(INVALID_SNIPPET_ID);

                Assert.Fail("Failed to throw exception");
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 400 Bad Request
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.BadRequest);
            }
        }
示例#5
0
        public async Task TestActivateDripCampaignWithInvalidParameters()
        {
            Trace.WriteLine(String.Format("POST /drip_campaigns/{0}/activate with invalid campaign ID", INVALID_CAMPAIGN_ID));

            // Build the drip campaign object
            var recipient    = new EmailRecipient(DEFAULT_RECIPIENT_EMAIL_ADDRESS);
            var dripCampaign = new DripCampaign(recipient);

            // Make the API call
            try {
                var response = await dripCampaign.ActivateAsync(INVALID_CAMPAIGN_ID);
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 400 Bad Request
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.BadRequest);
            }
        }
示例#6
0
        public async Task TestSendEmailWithInvalidTemplateId()
        {
            Trace.WriteLine("POST /send with an invalid template ID");

            // Constuct the email
            Email email = BuildBarebonesEmail();

            email.template = INVALID_TEMPLATE_ID;
            try
            {
                var response = await email.Send();

                Assert.Fail("Failed to throw exception");
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 400 Bad Request
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.BadRequest);
            }
        }
示例#7
0
        public async Task TestGetLogsWithInvalidCountAsync()
        {
            Trace.WriteLine("GET /logs");

            // Build the query parameters
            Dictionary <string, object> queryParameters = new Dictionary <string, object>();

            queryParameters.Add("count", INVALID_COUNT);

            // Make the API call
            try
            {
                var logs = await Log.GetLogsAsync(queryParameters);

                Assert.Fail("Failed to throw exception");
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 500 Internal Server Error
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.InternalServerError);
            }
        }
        public async Task TestGetEspAccountsWithInvalidParameterAsync()
        {
            Trace.WriteLine("GET /esp_accounts");

            // Build the query parameters
            var queryParameters = new Dictionary <string, object>();

            queryParameters.Add("esp_type", INVALID_ESP_ACCOUNT_TYPE);

            // Make the API call
            try
            {
                var response = await EspAccount.GetAccountsAsync(queryParameters);

                Assert.Fail("Failed to throw exception");
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 400 Bad Request
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.BadRequest);
            }
        }
        public async Task TestRenderTemplateWithInvalidIdAsync()
        {
            Trace.WriteLine("POST /render");

            // Build the object
            var templateData = new Dictionary <string, object>();

            templateData.Add("amount", "$12.00");
            var renderTemplate = new Render(INVALID_TEMPLATE_ID, templateData);

            // Make the API call
            try
            {
                var renderTemplateResponse = await renderTemplate.RenderTemplateAsync();

                Assert.Fail("Failed to throw exception");
            }
            catch (AggregateException exception)
            {
                // Make sure the response was HTTP 400 Bad Request
                SendwithusClientTest.ValidateException(exception, HttpStatusCode.BadRequest);
            }
        }