Ejemplo n.º 1
0
        public void ValidateWithSeveralRulesAndClassDefinitions_InvalidResult()
        {
            var validator = new ClassDefinitionValidator(_validationRuleMock1, _validationRuleMock2, _validationRuleMock3);

            _validationRuleMock1.Expect(mock => mock.Validate(_classDefinition1)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock1.Expect(mock => mock.Validate(_classDefinition2)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock1.Expect(mock => mock.Validate(_classDefinition3)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock2.Expect(mock => mock.Validate(_classDefinition1)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock2.Expect(mock => mock.Validate(_classDefinition2)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock2.Expect(mock => mock.Validate(_classDefinition3)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock3.Expect(mock => mock.Validate(_classDefinition1)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock3.Expect(mock => mock.Validate(_classDefinition2)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock3.Expect(mock => mock.Validate(_classDefinition3)).Return(_fakeInvalidMappingValidationResult);
            _validationRuleMock1.Replay();

            var mappingValidationResults = validator.Validate(new[] { _classDefinition1, _classDefinition2, _classDefinition3 }).ToArray();

            _validationRuleMock1.VerifyAllExpectations();
            Assert.That(validator.ValidationRules.Count, Is.EqualTo(3));
            Assert.That(mappingValidationResults.Length, Is.EqualTo(9));
            Assert.That(mappingValidationResults[0], Is.SameAs(_fakeInvalidMappingValidationResult));
            Assert.That(mappingValidationResults[1], Is.SameAs(_fakeInvalidMappingValidationResult));
            Assert.That(mappingValidationResults[2], Is.SameAs(_fakeInvalidMappingValidationResult));
            Assert.That(mappingValidationResults[3], Is.SameAs(_fakeInvalidMappingValidationResult));
            Assert.That(mappingValidationResults[4], Is.SameAs(_fakeInvalidMappingValidationResult));
            Assert.That(mappingValidationResults[5], Is.SameAs(_fakeInvalidMappingValidationResult));
            Assert.That(mappingValidationResults[6], Is.SameAs(_fakeInvalidMappingValidationResult));
            Assert.That(mappingValidationResults[7], Is.SameAs(_fakeInvalidMappingValidationResult));
            Assert.That(mappingValidationResults[8], Is.SameAs(_fakeInvalidMappingValidationResult));
        }
Ejemplo n.º 2
0
        public void ValidateWithOneRuleAndClassDefinition_ValidResult()
        {
            var validator = new ClassDefinitionValidator(_validationRuleMock1);

            _validationRuleMock1.Expect(mock => mock.Validate(_classDefinition1)).Return(_fakeValidMappingValidationResult);
            _validationRuleMock1.Replay();

            var mappingValidationResults = validator.Validate(new[] { _classDefinition1 }).ToArray();

            _validationRuleMock1.VerifyAllExpectations();
            Assert.That(validator.ValidationRules.Count, Is.EqualTo(1));
            Assert.That(mappingValidationResults.Length, Is.EqualTo(0));
        }