public void CSharpRulesXmlFileComplexIsPersistable( ) { IRulesLoader <BusinessEntity, CSharpRulesFactory <BusinessEntity> > loader = new XmlRulesLoader <BusinessEntity, CSharpRulesFactory <BusinessEntity> >( ); loader.AddRules("csharpRules.xml"); var businessEntity = new BusinessEntity( ); businessEntity.PersistenceRules.Add(loader.RulesFactory.FindRules(RuleType.Persistence)); businessEntity.BusinessRules.Add(loader.RulesFactory.FindRules(RuleType.Business)); businessEntity.Value = 6; businessEntity.Value2 = 6; businessEntity.Value3 = 0; businessEntity.Value4 = 6; businessEntity.Value5 = 6; Assert.IsFalse(businessEntity.IsPersistable( )); List <BrokenRuleData> brokenRules = new List <BrokenRuleData>( ); brokenRules.AddRange(businessEntity.GetAllBrokenRules( )); Assert.AreEqual <int>(1, brokenRules.Count); List <string> brokenRuleProperties = new List <string>( ); brokenRuleProperties.AddRange(brokenRules[0].Properties); Assert.AreEqual <int>(2, brokenRuleProperties.Count); Assert.AreEqual <string>("Value4", brokenRuleProperties[0]); Assert.AreEqual <string>("Value5", brokenRuleProperties[1]); }
public void FindAllTypes( ) { IRulesLoader <BusinessEntity, PythonRulesFactory <BusinessEntity> > loader = new XmlRulesLoader <BusinessEntity, PythonRulesFactory <BusinessEntity> >( ); loader.AddRules("pythonRules.xml"); loader.RulesFactory.FindRules(RuleType.All); }
public void CSharpRulesXmlFileIsValid( ) { IRulesLoader <BusinessEntity, CSharpRulesFactory <BusinessEntity> > loader = new XmlRulesLoader <BusinessEntity, CSharpRulesFactory <BusinessEntity> >( ); loader.AddRules("csharpRules.xml"); var businessEntity = new BusinessEntity( ); businessEntity.PersistenceRules.Add(loader.RulesFactory.FindRules(RuleType.Persistence)); businessEntity.Value = 1; businessEntity.Value2 = 1; Assert.IsFalse(businessEntity.IsPersistable( )); Assert.IsFalse(businessEntity.IsValid( )); }
public void PythonRulesXmlFileIsPersistableAndIsValid( ) { IRulesLoader <BusinessEntity, PythonRulesFactory <BusinessEntity> > loader = new XmlRulesLoader <BusinessEntity, PythonRulesFactory <BusinessEntity> >( ); loader.AddRules("pythonRules.xml"); var businessEntity = new BusinessEntity( ); businessEntity.PersistenceRules.Add(loader.RulesFactory.FindRules(RuleType.Persistence)); businessEntity.BusinessRules.Add(loader.RulesFactory.FindRules(RuleType.Business)); businessEntity.Value = 6; businessEntity.Value2 = 6; businessEntity.Value3 = -2; Assert.IsFalse(businessEntity.IsPersistable( )); Assert.IsFalse(businessEntity.IsValid( )); }
public void CSharpRulesXmlFileComplexIsPersistable( ) { IRulesLoader<BusinessEntity, CSharpRulesFactory<BusinessEntity>> loader = new XmlRulesLoader<BusinessEntity, CSharpRulesFactory<BusinessEntity>>( ); loader.AddRules( "csharpRules.xml" ); var businessEntity = new BusinessEntity( ); businessEntity.PersistenceRules.Add( loader.RulesFactory.FindRules( RuleType.Persistence ) ); businessEntity.BusinessRules.Add( loader.RulesFactory.FindRules( RuleType.Business ) ); businessEntity.Value = 6; businessEntity.Value2 = 6; businessEntity.Value3 = 0; businessEntity.Value4 = 6; businessEntity.Value5 = 6; Assert.IsFalse( businessEntity.IsPersistable( ) ); List<BrokenRuleData> brokenRules = new List<BrokenRuleData>( ); brokenRules.AddRange( businessEntity.GetAllBrokenRules( ) ); Assert.AreEqual<int>( 1, brokenRules.Count ); List<string> brokenRuleProperties = new List<string>( ); brokenRuleProperties.AddRange( brokenRules[ 0 ].Properties ); Assert.AreEqual<int>( 2, brokenRuleProperties.Count ); Assert.AreEqual<string>( "Value4", brokenRuleProperties[ 0 ] ); Assert.AreEqual<string>( "Value5", brokenRuleProperties[ 1 ] ); }
public void CSharpRulesXmlFileIsPersistableAndIsValid( ) { IRulesLoader<BusinessEntity, CSharpRulesFactory<BusinessEntity>> loader = new XmlRulesLoader<BusinessEntity, CSharpRulesFactory<BusinessEntity>>( ); loader.AddRules( "csharpRules.xml" ); var businessEntity = new BusinessEntity( ); businessEntity.PersistenceRules.Add( loader.RulesFactory.FindRules( RuleType.Persistence ) ); businessEntity.BusinessRules.Add( loader.RulesFactory.FindRules( RuleType.Business ) ); businessEntity.Value = 6; businessEntity.Value2 = 6; businessEntity.Value3 = -2; businessEntity.Value4 = 7; businessEntity.Value5 = 7; Assert.IsFalse( businessEntity.IsPersistable( ) ); Assert.IsFalse( businessEntity.IsValid( ) ); }
public void PythonRulesXmlFileIsPersistable( ) { IRulesLoader<BusinessEntity, PythonRulesFactory<BusinessEntity>> loader = new XmlRulesLoader<BusinessEntity, PythonRulesFactory<BusinessEntity>>( ); loader.AddRules( "pythonRules.xml" ); var businessEntity = new BusinessEntity( ); businessEntity.PersistenceRules.Add( loader.RulesFactory.FindRules( RuleType.Persistence ) ); businessEntity.BusinessRules.Add( loader.RulesFactory.FindRules( RuleType.Business ) ); businessEntity.Value = 6; businessEntity.Value2 = 1; Assert.IsTrue( businessEntity.IsPersistable( ) ); Assert.IsFalse( businessEntity.IsValid( ) ); }
public void FindAllTypes( ) { IRulesLoader<BusinessEntity, PythonRulesFactory<BusinessEntity>> loader = new XmlRulesLoader<BusinessEntity, PythonRulesFactory<BusinessEntity>>( ); loader.AddRules( "pythonRules.xml" ); loader.RulesFactory.FindRules( RuleType.All ); }