public static void Configure(IKernel kernel) { kernel.Bind<IMapper<ValidatedRabbitMqQueueMetadata, MessageQueueStatus>>().To<MessageQueueStatusMapper>(); kernel.Bind<IMapper<Simple.Validation.ValidationResult, Models.api.ValidationResult>>().To<ValidationResultMapper>(); kernel.Bind<ICommand<GetRabbitMqServerUrlRequest, GetRabbitMqServerUrlResponse>>().To<GetRabbitMqServerUrlCommand>(); kernel.Bind<ICommand<GetMonitorableQueuesRequest, GetMonitorableQueuesReponse>>().To<GetMonitorableQueuesCommand>(); kernel.Bind<ICommand<GetRabbitMqQueueMetadataRequest, GetRabbitMqQueueMetadataResponse>>().To<GetRabbitMqQueueMetadataCommand>(); kernel.Bind <ICommand<ValidateRabbitMqQueueMetadataRequest, ValidateRabbitMqQueueMetadataRequestResponse>>().To<ValidateRabbitMqQueueMetadataCommand>(); kernel.Bind<IValidator<RabbitMqQueueMetadata>>().To<RabbitMqQueueMetadataValidator>(); kernel.Bind<IValidationEngine>().ToMethod((context) => Validator.ValidationEngine); IValidatorProvider validatorProvider = new NinjectValidatorProvider(kernel); Validator.SetValidationEngine(new DefaultValidationEngine(validatorProvider)); }
public void GetValidators() { // Arrange var mockValidator = Substitute.For<IValidator<object>>(); mockValidator.AppliesTo("").Returns(true); var kernel = new StandardKernel(); kernel.Bind<IValidator<object>>().ToConstant(mockValidator); var provider = new NinjectValidatorProvider(kernel); // Act var validators = provider.GetValidators<object>(); // Assert Assert.That(validators, Is.Not.Empty); Assert.That(validators, Has.Member(mockValidator)); }