Esempio n. 1
0
            public void Should_Throw_On_Null_Settings_Parameter()
            {
                //Given
                HttpSettings settings = null;

                //When
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.EnsureSuccessStatusCode(settings));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, "settings");
            }
Esempio n. 2
0
            public void Should_Throw_On_Null_Settings_Parameter()
            {
                //Given
                HttpSettings settings    = null;
                string       requestBody = "{ \"id\":0, \"name\": \"testing\"}";

                //When
                var record = Record.Exception(() => HttpSettingsExtensions.SetRequestBody(settings, requestBody));

                //Then
                CakeAssert.IsArgumentNullException(record, "settings");
            }
Esempio n. 3
0
            public void Should_Throw_On_Null_Or_Empty_Data_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                BodyModel    data     = null;

                //When
                var actual = Record.Exception(() => HttpSettingsExtensions.SetJsonRequestBody(settings, data));

                //Then
                CakeAssert.IsArgumentNullException(actual, nameof(data));
            }
Esempio n. 4
0
            public void Should_Throw_On_Null_Or_Empty_Data_Parameter()
            {
                //Given
                HttpSettings settings             = new HttpSettings();
                IDictionary <string, string> data = null;

                //When
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.SetFormUrlEncodedRequestBody(settings, data));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(data));
            }
Esempio n. 5
0
            public void Should_Throw_On_Null_Settings_Parameter()
            {
                //Given
                HttpSettings settings = null;
                string       name     = "Content-Type";
                string       value    = "applicaion/json";

                //When
                var record = Record.Exception(() => HttpSettingsExtensions.AppendHeader(settings, name, value));

                //Then
                CakeAssert.IsArgumentNullException(record, "settings");
            }
Esempio n. 6
0
            public void Should_Throw_On_Null_Settings_Parameter()
            {
                //Given
                HttpSettings settings = null;
                string       name     = "sessionid";
                string       value    = "1BA9481B-74C1-42B3-A1B9-0B914BAE0F05";

                //When
                var record = Record.Exception(() => HttpSettingsExtensions.AppendCookie(settings, name, value));

                //Then
                CakeAssert.IsArgumentNullException(record, "settings");
            }
Esempio n. 7
0
            public void Should_Throw_On_Null_Settings_Parameter()
            {
                //Given
                HttpSettings settings = null;
                BodyModel    model    = new BodyModel {
                    Id = 1234567, Active = true, name = "Rob Test"
                };

                //When
                var record = Record.Exception(() => HttpSettingsExtensions.SetJsonRequestBody(settings, model));

                //Then
                CakeAssert.IsArgumentNullException(record, "settings");
            }
Esempio n. 8
0
            public void Should_Throw_On_Null_Or_Empty_Name_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       value    = "applicaion/json";

                //When
                var nullRecord  = Record.Exception(() => HttpSettingsExtensions.AppendHeader(settings, null, value));
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.AppendHeader(settings, "", value));
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.AppendHeader(settings, "   ", value));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, "name");
                CakeAssert.IsArgumentNullException(emptyRecord, "name");
                CakeAssert.IsArgumentNullException(spaceRecord, "name");
            }
Esempio n. 9
0
            public void Should_Throw_On_Null_Or_Empty_Schema_Parameter()
            {
                //Given
                HttpSettings settings  = new HttpSettings();
                string       parameter = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cnVlLCJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0.yRQYnWzskCZUxPwaQupWkiUzKELZ49eM7oWxAQK_ZXw";

                //When
                var nullRecord  = Record.Exception(() => HttpSettingsExtensions.SetAuthorization(settings, null, parameter));
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.SetAuthorization(settings, "", parameter));
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.SetAuthorization(settings, "   ", parameter));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, "schema");
                CakeAssert.IsArgumentNullException(emptyRecord, "schema");
                CakeAssert.IsArgumentNullException(spaceRecord, "schema");
            }
Esempio n. 10
0
            public void Should_Throw_On_Null_Or_Empty_Value_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       name     = "Content-Type";

                //When
                var nullRecord  = Record.Exception(() => HttpSettingsExtensions.AppendHeader(settings, name, null));
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.AppendHeader(settings, name, ""));
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.AppendHeader(settings, name, "   "));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, "value");
                CakeAssert.IsArgumentNullException(emptyRecord, "value");
                CakeAssert.IsArgumentNullException(spaceRecord, "value");
            }
Esempio n. 11
0
            public void Should_Throw_On_Null_Or_Empty_Parameter_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       schema   = "Bearer";

                //When
                var nullRecord  = Record.Exception(() => HttpSettingsExtensions.SetAuthorization(settings, schema, null));
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.SetAuthorization(settings, schema, ""));
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.SetAuthorization(settings, schema, "   "));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, "parameter");
                CakeAssert.IsArgumentNullException(emptyRecord, "parameter");
                CakeAssert.IsArgumentNullException(spaceRecord, "parameter");
            }
Esempio n. 12
0
            public void Should_Throw_On_Null_Or_Empty_Token_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       token    = null;

                //When
                token = null;
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.UseBearerAuthorization(settings, token));

                token = string.Empty;
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.UseBearerAuthorization(settings, token));

                token = "      ";
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.UseBearerAuthorization(settings, token));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(token));
                CakeAssert.IsArgumentNullException(emptyRecord, nameof(token));
                CakeAssert.IsArgumentNullException(spaceRecord, nameof(token));
            }
Esempio n. 13
0
            public void Should_Throw_On_Null_Or_Empty_RequestBody_Parameter()
            {
                //Given
                HttpSettings settings    = new HttpSettings();
                string       requestBody = null;

                //When
                requestBody = null;
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.SetRequestBody(settings, requestBody));

                requestBody = string.Empty;
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.SetRequestBody(settings, requestBody));

                requestBody = "      ";
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.SetRequestBody(settings, requestBody));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(requestBody));
                CakeAssert.IsArgumentNullException(emptyRecord, nameof(requestBody));
                CakeAssert.IsArgumentNullException(spaceRecord, nameof(requestBody));
            }
Esempio n. 14
0
            public void Should_Throw_On_Null_Or_Empty_Url_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       url      = null;

                //When
                url = null;
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.SetReferer(settings, url));

                url = string.Empty;
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.SetReferer(settings, url));

                url = "      ";
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.SetReferer(settings, url));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(url));
                CakeAssert.IsArgumentNullException(emptyRecord, nameof(url));
                CakeAssert.IsArgumentNullException(spaceRecord, nameof(url));
            }
Esempio n. 15
0
            public void Should_Throw_On_Null_Or_Empty_Accept_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       accept   = null;

                //When
                accept = null;
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.SetAccept(settings, accept));

                accept = string.Empty;
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.SetAccept(settings, accept));

                accept = "      ";
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.SetAccept(settings, accept));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(accept));
                CakeAssert.IsArgumentNullException(emptyRecord, nameof(accept));
                CakeAssert.IsArgumentNullException(spaceRecord, nameof(accept));
            }
Esempio n. 16
0
            public void Should_Throw_On_Null_Or_Empty_ContentType_Parameter()
            {
                //Given
                HttpSettings settings    = new HttpSettings();
                string       contentType = null;

                //When
                contentType = null;
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.SetContentType(settings, contentType));

                contentType = string.Empty;
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.SetContentType(settings, contentType));

                contentType = "      ";
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.SetContentType(settings, contentType));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(contentType));
                CakeAssert.IsArgumentNullException(emptyRecord, nameof(contentType));
                CakeAssert.IsArgumentNullException(spaceRecord, nameof(contentType));
            }
Esempio n. 17
0
            public void Should_Throw_On_Null_Or_Empty_Value_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       name     = "sessionid";
                string       value    = null;

                //When
                value = null;
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.AppendCookie(settings, name, value));

                value = string.Empty;
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.AppendCookie(settings, name, value));

                value = "      ";
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.AppendCookie(settings, name, value));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(value));
                CakeAssert.IsArgumentNullException(emptyRecord, nameof(value));
                CakeAssert.IsArgumentNullException(spaceRecord, nameof(value));
            }
Esempio n. 18
0
            public void Should_Throw_On_Null_Or_Empty_Name_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       name     = null;
                string       value    = "1BA9481B-74C1-42B3-A1B9-0B914BAE0F05";

                //When
                name = null;
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.AppendCookie(settings, name, value));

                name = string.Empty;
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.AppendCookie(settings, name, value));

                name = "      ";
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.AppendCookie(settings, name, value));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(name));
                CakeAssert.IsArgumentNullException(emptyRecord, nameof(name));
                CakeAssert.IsArgumentNullException(spaceRecord, nameof(name));
            }
Esempio n. 19
0
            public void Should_Throw_On_Null_Or_Empty_Password_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                string       userName = "******";
                string       password = null;

                //When
                password = null;
                var nullRecord = Record.Exception(() => HttpSettingsExtensions.UseBasicAuthorization(settings, userName, password));

                password = string.Empty;
                var emptyRecord = Record.Exception(() => HttpSettingsExtensions.UseBasicAuthorization(settings, userName, password));

                password = "******";
                var spaceRecord = Record.Exception(() => HttpSettingsExtensions.UseBasicAuthorization(settings, userName, password));

                //Then
                CakeAssert.IsArgumentNullException(nullRecord, nameof(password));
                CakeAssert.IsArgumentNullException(emptyRecord, nameof(password));
                CakeAssert.IsArgumentNullException(spaceRecord, nameof(password));
            }