public void IsNotOfType_WhenIsNotTheType_It_should_not_throw() => ShouldNotThrow( () => Ensure.Type.IsNotOfType(BogusType, NonBogusType, ParamName), () => Ensure.Type.IsNotOfType(new Bogus(), NonBogusType, ParamName), () => EnsureArg.IsNotOfType(BogusType, NonBogusType, ParamName), () => EnsureArg.IsNotOfType(new Bogus(), NonBogusType, ParamName), () => Ensure.ThatType(typeof(Bogus), ParamName).IsNotOfType(NonBogusType), () => Ensure.ThatTypeFor(new Bogus(), ParamName).IsNotOfType(NonBogusType));
public void IsNotOfType_WhenTypeOf_ThrowsArgumentException() => ShouldThrow <ArgumentException>( string.Format(ExceptionMessages.Types_IsNotOfType_Failed, BogusType), () => Ensure.Type.IsNotOfType(typeof(Bogus), BogusType, ParamName), () => Ensure.Type.IsNotOfType(new Bogus(), BogusType, ParamName), () => EnsureArg.IsNotOfType(typeof(Bogus), BogusType, ParamName), () => EnsureArg.IsNotOfType(new Bogus(), BogusType, ParamName), () => Ensure.ThatType(typeof(Bogus), ParamName).IsNotOfType(BogusType), () => Ensure.ThatTypeFor(new Bogus(), ParamName).IsNotOfType(BogusType));
protected override void AddChild(Node child) { EnsureArg.IsNotNull(child, nameof(child)); EnsureArg.IsNotOfType( param: child, nonExpectedType: typeof(NamespaceNode), paramName: nameof(child), optsFn: options => options.WithMessage("Namespace cannot be added to a class") ); Children.Add(child); }
public void IsNotOfType_WhenIsNotTheType_It_should_not_throw() { var returnedValue = Ensure.ThatTypeFor(new Bogus(), ParamName).IsNotOfType(NonBogusType); AssertReturnedAsExpected(returnedValue, BogusType); Action a = () => EnsureArg.IsNotOfType(BogusType, NonBogusType, ParamName); a.ShouldNotThrow(); Action b = () => EnsureArg.IsNotOfType(new Bogus(), NonBogusType, ParamName); b.ShouldNotThrow(); }