public void ThrowsArgumentNullExceptionForNullValidator()
            {
                var compositeValidatorProvider = new CompositeValidatorProvider();

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(
                    () => compositeValidatorProvider.Remove(null));
            }
 public void EliminatesAnAlreadyAddedValidator()
 {
     var compositeValidatorProvider = new CompositeValidatorProvider();
     var validatorProviderMock1 = new Moq.Mock<IValidatorProvider>();
     var validatorProviderMock2 = new Moq.Mock<IValidatorProvider>();
     
     compositeValidatorProvider.Add(validatorProviderMock1.Object);
     compositeValidatorProvider.Add(validatorProviderMock2.Object);
     
     compositeValidatorProvider.Remove(validatorProviderMock1.Object);
     Assert.IsFalse(compositeValidatorProvider.Contains(validatorProviderMock1.Object));
 }
            public void RetrieveTheRightValidatorComposition()
            {
                var compositeValidatorProvider = new CompositeValidatorProvider();
                var validatorMock1 = new Moq.Mock<IValidator>();
                var validatorMock2 = new Moq.Mock<IValidator>();

                var validatorProviderMock1 = new Moq.Mock<IValidatorProvider>();
                validatorProviderMock1.Setup(provider => provider.GetValidator(typeof(FooViewModel))).Returns(validatorMock1.Object);

                var validatorProviderMock2 = new Moq.Mock<IValidatorProvider>();
                validatorProviderMock2.Setup(provider => provider.GetValidator(typeof(FooViewModel))).Returns(validatorMock2.Object);

                compositeValidatorProvider.Add(validatorProviderMock1.Object);
                compositeValidatorProvider.Add(validatorProviderMock2.Object);

                IValidator validator = (compositeValidatorProvider as IValidatorProvider).GetValidator<FooViewModel>();

                Assert.IsInstanceOfType(validator, typeof(CompositeValidator));
                ((CompositeValidator)validator).Contains(validatorMock1.Object);
                ((CompositeValidator)validator).Contains(validatorMock2.Object);
            }
            public void RetrieveTheRightSingleValidator()
            {
                var compositeValidatorProvider = new CompositeValidatorProvider();
                var validatorMock1 = new Moq.Mock<IValidator>();

                var validatorProviderMock1 = new Moq.Mock<IValidatorProvider>();
                validatorProviderMock1.Setup(provider => provider.GetValidator(typeof(FooViewModel))).Returns(validatorMock1.Object);

                var validatorProviderMock2 = new Moq.Mock<IValidatorProvider>();
                validatorProviderMock2.Setup(provider => provider.GetValidator(typeof(FooViewModel))).Returns(default(IValidator));

                compositeValidatorProvider.Add(validatorProviderMock1.Object);
                compositeValidatorProvider.Add(validatorProviderMock2.Object);

                IValidator validator = (compositeValidatorProvider as IValidatorProvider).GetValidator<FooViewModel>();

                Assert.AreEqual(validator, validatorMock1.Object);
            }