public void CreateRelationEndPointDefinitionCollection() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(OrderTicket)); var propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(classDefinition); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition }, true)); var fakeRelationEndPoint = new RelationEndPointDefinition(propertyDefinition, false); var expectedPropertyInfo = PropertyInfoAdapter.Create(typeof(OrderTicket).GetProperty("Order")); _mappingObjectFactoryMock .Expect( mock => mock.CreateRelationEndPointDefinition( Arg.Is(classDefinition), Arg.Is(PropertyInfoAdapter.Create(expectedPropertyInfo.PropertyInfo)))) .Return(fakeRelationEndPoint); _mappingObjectFactoryMock.Replay(); var result = _factory.CreateRelationEndPointDefinitionCollection(classDefinition); _mappingObjectFactoryMock.VerifyAllExpectations(); _memberInformationNameResolverMock.VerifyAllExpectations(); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result[0], Is.SameAs(fakeRelationEndPoint)); }
public void BuildValidator() { ExpectMocks(); _collectorValidatorMock.Expect(mock => mock.CheckValid(_componenValidationCollectorStub1)).Repeat.Once(); _collectorValidatorMock.Expect(mock => mock.CheckValid(_componenValidationCollectorStub2)).Repeat.Once(); _collectorValidatorMock.Expect(mock => mock.CheckValid(_componenValidationCollectorStub3)).Repeat.Once(); _metaRuleValidatorMock .Expect(mock => mock.Validate(Arg <IValidationRule[]> .List.Equal(_fakeValidationRuleResult))) .Return(new[] { _validMetaValidationResult1, _validMetaValidationResult2 }); _memberInformationNameResolverMock .Expect(mock => mock.GetPropertyName(Arg <IPropertyInformation> .Matches(pi => pi.Name == "FirstName"))) .Return("FakeTechnicalPropertyName1"); _memberInformationNameResolverMock .Expect(mock => mock.GetPropertyName(Arg <IPropertyInformation> .Matches(pi => pi.Name == "LastName"))) .Return("FakeTechnicalPropertyName2"); _validationRuleGlobalizationServiceMock .Expect(mock => mock.ApplyMetadata(_validationRuleStub1, typeof(SpecialCustomer1))); _validationRuleGlobalizationServiceMock .Expect(mock => mock.ApplyMetadata(_validationRuleStub2, typeof(SpecialCustomer1))); _validationRuleGlobalizationServiceMock .Expect(mock => mock.ApplyMetadata(_validationRuleStub3, typeof(SpecialCustomer1))); _validationRuleGlobalizationServiceMock .Expect(mock => mock.ApplyMetadata(_validationRuleStub4, typeof(SpecialCustomer1))); var result = _fluentValidationBuilder.BuildValidator(typeof(SpecialCustomer1)); _validationCollectorProviderMock.VerifyAllExpectations(); _validationCollectorMergerMock.VerifyAllExpectations(); _metaRuleValidatorMock.VerifyAllExpectations(); _memberInformationNameResolverMock.VerifyAllExpectations(); _validationRuleGlobalizationServiceMock.VerifyAllExpectations(); Assert.That(result, Is.TypeOf(typeof(Validator))); var validator = (Validator)result; Assert.That(validator.ValidationRules, Is.EqualTo(_fakeValidationRuleResult)); Assert.That(_validationRuleStub3.PropertyName, Is.EqualTo("FakeTechnicalPropertyName1")); Assert.That(_validationRuleStub4.PropertyName, Is.EqualTo("FakeTechnicalPropertyName2")); }