Ejemplo n.º 1
0
 public void IsString_WhenNotTypeOf_ThrowsArgumentException() => AssertIsOfTypeScenario(
     typeof(string), typeof(int),
     () => Ensure.Type.IsString(typeof(int), ParamName),
     () => Ensure.Type.IsString(42, ParamName),
     () => EnsureArg.IsString(typeof(int), ParamName),
     () => EnsureArg.IsString(42, ParamName),
     () => Ensure.ThatType(typeof(int), ParamName).IsString(),
     () => Ensure.ThatTypeFor(42, ParamName).IsString());
Ejemplo n.º 2
0
        public void IsString_WhenIsCorrectType_It_should_not_throw()
        {
            var value = string.Empty;

            ShouldNotThrow(
                () => Ensure.ThatTypeFor(value, ParamName).IsString(),
                () => EnsureArg.IsString(typeof(string), ParamName),
                () => EnsureArg.IsString(value, ParamName));
        }
Ejemplo n.º 3
0
        public void IsString_WhenIsCorrectType_It_should_not_throw()
        {
            var value = string.Empty;

            var returnedValue = Ensure.ThatTypeFor(value, ParamName).IsString();

            AssertReturnedAsExpected(returnedValue, typeof(string));

            Action a = () => EnsureArg.IsString(typeof(string), ParamName);

            a.ShouldNotThrow();

            Action b = () => EnsureArg.IsString(value, ParamName);

            b.ShouldNotThrow();
        }