Пример #1
0
        public void GuardAgainstNullOrWhiteSpace_NotEmpty_DoesNotThrowsException()
        {
            string param = "value";

            Assert.DoesNotThrows(() => Guard.Against.NullOrWhiteSpace(param, nameof(param)));
            Assert.DoesNotThrows(() => Guard.Against.NullOrWhiteSpace(param, nameof(param), "My custom error message"));
        }
Пример #2
0
 public void GuardAgainstNotEmpty_Empty_DoesNotThrows()
 {
     Assert.DoesNotThrows(() =>
     {
         var myGuid = Guid.Empty;
         Guard.Against.NotEmpty(myGuid, nameof(myGuid));
     });
 }
Пример #3
0
 public void CreateInstance_NullOrEmptyNif_InstanceCreated(string nullOrEmptyNif)
 {
     Assert.DoesNotThrows(() =>
     {
         var nif = ActivatorHelper.CreateInstance <Nif>(nullOrEmptyNif);
         Assert.NotNull(nif);
     });
 }
Пример #4
0
 public void DoesNotThrows_TestCode_DoesNotThrows()
 {
     Assert.DoesNotThrows(() =>
     {
         object param = new object();
         Guard.Against.Null(param, nameof(param));
     });
 }
Пример #5
0
 public void CreateInstance_NotEmptyNif_InstanceCreated(string notEmptyNif)
 {
     Assert.DoesNotThrows(() =>
     {
         var nif = ActivatorHelper.CreateInstance <Nif>(notEmptyNif);
         Assert.NotNull(nif);
         Assert.Equal(notEmptyNif, nif.Value);
     });
 }
Пример #6
0
 public void GuardAgainstTrue_False_DoesNotThrows()
 {
     Assert.DoesNotThrows(() =>
     {
         bool myParam = false;
         Guard.Against.True(myParam, nameof(myParam));
         Guard.Against.True(_ => "a" == "b", nameof(myParam));
     });
 }
Пример #7
0
 public void GuardAgainstFalse_True_DoesNotThrows()
 {
     Assert.DoesNotThrows(() =>
     {
         bool myParam = true;
         Guard.Against.False(myParam, nameof(myParam));
         Guard.Against.False(_ => "ab" == "ab", nameof(myParam));
     });
 }
Пример #8
0
        public void GuardAgainstNotEmpty_Empty_DoesNotThrows()
        {
            Assert.DoesNotThrows(() =>
            {
                var myCollection1 = new List <int>();
                Guard.Against.NotEmpty(myCollection1, nameof(myCollection1));

                var myCollection2 = new List <string>();
                Guard.Against.NotEmpty(myCollection1, nameof(myCollection2));
            });
        }
        public void EnsureContentType_DefaultContentType_DoesNotThrowsException()
        {
            var response1 = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(string.Empty, Encoding.UTF8, "application/json")
            };

            Assert.DoesNotThrows(() => response1.EnsureContentType());

            var response2 = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(string.Empty, Encoding.ASCII, "text/html")
            };

            Assert.DoesNotThrows(() => response2.EnsureContentType("text/html; charset=us-ascii"));
        }
Пример #10
0
        public void GuardAgainstNull_NotNull_DoesNotThrowsException()
        {
            Assert.DoesNotThrows(() =>
            {
                object param = new object();
                Guard.Against.Null(param, nameof(param));
            });

            Assert.DoesNotThrows(() =>
            {
                object param1 = new object();
                object param2 = new object();
                object param3 = new object();
                object param4 = new object();

                Guard.Against
                .Null(param1, nameof(param1))
                .Null(param2, nameof(param2))
                .Null(param3, nameof(param3))
                .Null(param4, nameof(param4));
            });
        }
Пример #11
0
 public void GuardAgainstPositive_ZeroAndNegative_DoesNotThrowsException(int zeroAndNegative)
 {
     Assert.DoesNotThrows(() => Guard.Against.Positive(zeroAndNegative, nameof(zeroAndNegative)));
     Assert.DoesNotThrows(() => Guard.Against.Positive(Convert.ToDecimal(zeroAndNegative), nameof(zeroAndNegative)));
     Assert.DoesNotThrows(() => Guard.Against.Positive(Convert.ToDouble(zeroAndNegative), nameof(zeroAndNegative)));
 }
Пример #12
0
        public void GuardAgainstInvalidEmail_ValidEmail_DoesNotThrowsException()
        {
            const string validEmail = "*****@*****.**";

            Assert.DoesNotThrows(() => Guard.Against.InvalidEmail(validEmail));
        }
Пример #13
0
        public void GuardAgainstNullOrEmpty_NotEmpty_DoesNotThrowsException()
        {
            string param1 = "value";

            Assert.DoesNotThrows(() => Guard.Against.NullOrEmpty(param1, nameof(param1)));
        }
Пример #14
0
 public void GuardAgainstMinLength_MinLength_DoesNotThrows(string myParam)
 {
     Assert.DoesNotThrows(() => Guard.Against.MinLength(3, myParam, nameof(myParam)));
 }
Пример #15
0
 public void NewEmail_ValidEmail_DoesNotThrowsException(string validEmail)
 {
     Assert.DoesNotThrows(() => new Email(validEmail));
     Assert.DoesNotThrows(() => (Email)validEmail);
     Assert.DoesNotThrows(() => Email.NewEmail(validEmail));
 }
Пример #16
0
 public void GuardAgainstInvalidNif_ValidNif_DoesNotThrows(string validNif)
 {
     Assert.DoesNotThrows(() => Guard.Against.InvalidNif(validNif));
 }
Пример #17
0
 public void GuardAgainstZero_GreaterOrLessThanZero_DoesNotThrowsException(int greaterOrLessThanZero)
 {
     Assert.DoesNotThrows(() => Guard.Against.Zero(greaterOrLessThanZero, nameof(greaterOrLessThanZero)));
     Assert.DoesNotThrows(() => Guard.Against.Zero(Convert.ToDecimal(greaterOrLessThanZero), nameof(greaterOrLessThanZero)));
     Assert.DoesNotThrows(() => Guard.Against.Zero(Convert.ToDouble(greaterOrLessThanZero), nameof(greaterOrLessThanZero)));
 }
Пример #18
0
 public void NewNif_ValidNif_DoesNotThrowsException(string validNif)
 {
     Assert.DoesNotThrows(() => new Nif(validNif));
     Assert.DoesNotThrows(() => (Nif)validNif);
     Assert.DoesNotThrows(() => Nif.NewNif(validNif));
 }
Пример #19
0
 public void GuardAgainstZeroOrLess_Positive_DoesNotThrowsException(int positive)
 {
     Assert.DoesNotThrows(() => Guard.Against.ZeroOrLess(positive, nameof(positive)));
     Assert.DoesNotThrows(() => Guard.Against.ZeroOrLess(Convert.ToDecimal(positive), nameof(positive)));
     Assert.DoesNotThrows(() => Guard.Against.ZeroOrLess(Convert.ToDouble(positive), nameof(positive)));
 }
Пример #20
0
 public void NewUrl_ValidUrl_DoesNotThrowsException(string validUrl)
 {
     Assert.DoesNotThrows(() => new Url(validUrl));
     Assert.DoesNotThrows(() => (Url)validUrl);
     Assert.DoesNotThrows(() => Url.NewUrl(validUrl));
 }
Пример #21
0
 public void GuardAgainstGreaterThan5_EqualOrLessThan5_DoesNotThrowsException(int equalOrLessThan5)
 {
     Assert.DoesNotThrows(() => Guard.Against.GreaterThan(5, equalOrLessThan5, nameof(equalOrLessThan5)));
     Assert.DoesNotThrows(() => Guard.Against.GreaterThan(Convert.ToDecimal(5), Convert.ToDecimal(equalOrLessThan5), nameof(equalOrLessThan5)));
     Assert.DoesNotThrows(() => Guard.Against.GreaterThan(Convert.ToDouble(5), Convert.ToDouble(equalOrLessThan5), nameof(equalOrLessThan5)));
 }
Пример #22
0
 public void GuardAgainstNotMatch_PatternMatched_DoesNotThrows(string myParam, string pattern)
 {
     Assert.DoesNotThrows(() => Guard.Against.NotMatch(myParam, pattern, nameof(myParam)));
 }
Пример #23
0
        public void GuardAgainstNotExists_Exists_DoesNotThrows(int value)
        {
            var orderStatus = (OrderStatus)value;

            Assert.DoesNotThrows(() => Guard.Against.NotExists(orderStatus));
        }