16,019,983 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Scyldshefing (Top 4 by date)
Scyldshefing
31-Dec-16 6:47am
View
Deleted
(Please ignore this comment - I have tried deleting it - It would appear that the posting of xml samples into this site corrupts or looses the terminating element- sorry)
The sample XML you have provided is not a valid XML (which may be the root cause of your problem). Every node in an xml must have an opening and closing elemeny e.g. <corporatename>Prima S. A. should be <corporatename>Prima S. A..</corporatename> Even nodes that contain other nodes e.g. the legalentity in your example sholud have a closing element. (there is a speical case for empty nodes which can be either <postcode> or <postcode> )
e.g. your sample
<legalentity> <corporatename>Prima S. A. <addressinspain>
Street San Vicente, 1
<postcode>41008 <town>Seville <province>Seville <countrycode>ESP
should look more like (I am guesing)
<legalentity>
<corporatename>Prima S. A.
<addressinspain>Street San Vicente, 1
<postcode>41008
<town>Seville
<province>Seville
<countrycode>ESP
Once you have the correct XML format of your target (sample) then you can verify if your code is working or not.
Scyldshefing
30-Dec-16 9:02am
View
I have posted the code to the GitHub @ https://github.com/Scyldshefing/RulesEngineII
Scyldshefing
30-Dec-16 8:21am
View
I cannot use void as a return type in the Lambda expression (certainly not the way I tried it).
if (expressionToCompile != null)
{
ruleDefinition.CompiledExpression =
Expression.Lambda<Func<T, void>>(expressionToCompile, parameter).Compile();
}
gets the following error message:
Keyword 'void' cannot be used in this context
If I replace the int with object and remove the Expression.Constant line I get the following exception in my unit test:
Test Name: TestIfThenElseCondition
Test FullName: UnitTestProject1.GivenIfThenElse.TestIfThenElseCondition
Test Source: c:\VSSolution\RulesEngine\UnitTestProject1\GivenIfThenElse.cs : line 17
Test Outcome: Failed
Test Duration: 0:00:00.0014237
Result Message:
Test method UnitTestProject1.GivenIfThenElse.TestIfThenElseCondition threw exception:
System.ArgumentException: Expression of type 'System.Void' cannot be used for return type 'System.Object'
Result StackTrace:
at System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType, Expression& body, ReadOnlyCollection`1 parameters)
at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, String name, Boolean tailCall, IEnumerable`1 parameters)
at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, Boolean tailCall, IEnumerable`1 parameters)
at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, ParameterExpression[] parameters)
at RulesEngine.RulesHelper.CompileRuleDefinition[T](RuleDefinition`1 ruleDefinition) in c:\VSSolution\RulesEngine\RulesEngine\RulesHelper.cs:line 111
at RulesEngine.RulesHelper.CompileRuleSet[T](RuleSet`1 ruleSet) in c:\VSSolution\RulesEngine\RulesEngine\RulesHelper.cs:line 71
at UnitTestProject1.GivenIfThenElse.TestIfThenElseCondition() in c:\VSSolution\RulesEngine\UnitTestProject1\GivenIfThenElse.cs:line 34
Scyldshefing
3-Nov-16 3:23am
View
Given that Employee implements IEmployee and both these classes are defined, how are you injecting the mock object (objMock.Object) into the code that is being tested. Your snippet does not show the declaration of the Employee object in the code under test.
To do this sort of thing (Dependency Injection) I use the Microsoft Unityframework (https://msdn.microsoft.com/en-us/library/ff647202.aspx )