コード例 #1
0
ファイル: CoreFixture.cs プロジェクト: oflores/confsamples
        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]);
        }
コード例 #2
0
ファイル: CoreFixture.cs プロジェクト: oflores/confsamples
        public void FindAllTypes( )
        {
            IRulesLoader <BusinessEntity, PythonRulesFactory <BusinessEntity> > loader = new XmlRulesLoader <BusinessEntity, PythonRulesFactory <BusinessEntity> >( );

            loader.AddRules("pythonRules.xml");

            loader.RulesFactory.FindRules(RuleType.All);
        }
コード例 #3
0
ファイル: CoreFixture.cs プロジェクト: oflores/confsamples
        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( ));
        }
コード例 #4
0
ファイル: CoreFixture.cs プロジェクト: oflores/confsamples
        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( ));
        }
コード例 #5
0
ファイル: CoreFixture.cs プロジェクト: julid29/confsamples
		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 ] );
		}
コード例 #6
0
ファイル: CoreFixture.cs プロジェクト: julid29/confsamples
		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( ) );
		}
コード例 #7
0
ファイル: CoreFixture.cs プロジェクト: julid29/confsamples
		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( ) );
		}
コード例 #8
0
ファイル: CoreFixture.cs プロジェクト: julid29/confsamples
		public void FindAllTypes( )
		{
			IRulesLoader<BusinessEntity, PythonRulesFactory<BusinessEntity>> loader = new XmlRulesLoader<BusinessEntity, PythonRulesFactory<BusinessEntity>>( );

			loader.AddRules( "pythonRules.xml" );

			loader.RulesFactory.FindRules( RuleType.All );
		}