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")); }
public void GuardAgainstNotEmpty_Empty_DoesNotThrows() { Assert.DoesNotThrows(() => { var myGuid = Guid.Empty; Guard.Against.NotEmpty(myGuid, nameof(myGuid)); }); }
public void CreateInstance_NullOrEmptyNif_InstanceCreated(string nullOrEmptyNif) { Assert.DoesNotThrows(() => { var nif = ActivatorHelper.CreateInstance <Nif>(nullOrEmptyNif); Assert.NotNull(nif); }); }
public void DoesNotThrows_TestCode_DoesNotThrows() { Assert.DoesNotThrows(() => { object param = new object(); Guard.Against.Null(param, nameof(param)); }); }
public void CreateInstance_NotEmptyNif_InstanceCreated(string notEmptyNif) { Assert.DoesNotThrows(() => { var nif = ActivatorHelper.CreateInstance <Nif>(notEmptyNif); Assert.NotNull(nif); Assert.Equal(notEmptyNif, nif.Value); }); }
public void GuardAgainstTrue_False_DoesNotThrows() { Assert.DoesNotThrows(() => { bool myParam = false; Guard.Against.True(myParam, nameof(myParam)); Guard.Against.True(_ => "a" == "b", nameof(myParam)); }); }
public void GuardAgainstFalse_True_DoesNotThrows() { Assert.DoesNotThrows(() => { bool myParam = true; Guard.Against.False(myParam, nameof(myParam)); Guard.Against.False(_ => "ab" == "ab", nameof(myParam)); }); }
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")); }
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)); }); }
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))); }
public void GuardAgainstInvalidEmail_ValidEmail_DoesNotThrowsException() { const string validEmail = "*****@*****.**"; Assert.DoesNotThrows(() => Guard.Against.InvalidEmail(validEmail)); }
public void GuardAgainstNullOrEmpty_NotEmpty_DoesNotThrowsException() { string param1 = "value"; Assert.DoesNotThrows(() => Guard.Against.NullOrEmpty(param1, nameof(param1))); }
public void GuardAgainstMinLength_MinLength_DoesNotThrows(string myParam) { Assert.DoesNotThrows(() => Guard.Against.MinLength(3, myParam, nameof(myParam))); }
public void NewEmail_ValidEmail_DoesNotThrowsException(string validEmail) { Assert.DoesNotThrows(() => new Email(validEmail)); Assert.DoesNotThrows(() => (Email)validEmail); Assert.DoesNotThrows(() => Email.NewEmail(validEmail)); }
public void GuardAgainstInvalidNif_ValidNif_DoesNotThrows(string validNif) { Assert.DoesNotThrows(() => Guard.Against.InvalidNif(validNif)); }
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))); }
public void NewNif_ValidNif_DoesNotThrowsException(string validNif) { Assert.DoesNotThrows(() => new Nif(validNif)); Assert.DoesNotThrows(() => (Nif)validNif); Assert.DoesNotThrows(() => Nif.NewNif(validNif)); }
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))); }
public void NewUrl_ValidUrl_DoesNotThrowsException(string validUrl) { Assert.DoesNotThrows(() => new Url(validUrl)); Assert.DoesNotThrows(() => (Url)validUrl); Assert.DoesNotThrows(() => Url.NewUrl(validUrl)); }
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))); }
public void GuardAgainstNotMatch_PatternMatched_DoesNotThrows(string myParam, string pattern) { Assert.DoesNotThrows(() => Guard.Against.NotMatch(myParam, pattern, nameof(myParam))); }
public void GuardAgainstNotExists_Exists_DoesNotThrows(int value) { var orderStatus = (OrderStatus)value; Assert.DoesNotThrows(() => Guard.Against.NotExists(orderStatus)); }