-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using aggregator; | ||
using aggregator.Engine; | ||
using NSubstitute; | ||
using Xunit; | ||
using Xunit.Priority; | ||
|
||
namespace unittests_ruleng | ||
{ | ||
[TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)] | ||
public class RuleCachingTests | ||
{ | ||
#if DEBUG | ||
[Fact, Priority(0)] | ||
public void GivenTheSameRule_WhenTheRuleIsParsedThrice_ThenTheLogger_LogsThatWasFoundInCache() | ||
{ | ||
//Given | ||
var logger = Substitute.For<IAggregatorLogger>(); | ||
string ruleName = "dummy"; | ||
var ruleCode = new[] { "" }; | ||
|
||
//When | ||
_ = new ScriptedRuleWrapper(ruleName, ruleCode, logger); | ||
_ = new ScriptedRuleWrapper(ruleName, ruleCode, logger); | ||
_ = new ScriptedRuleWrapper(ruleName, ruleCode, logger); | ||
|
||
//Then | ||
logger.Received(1).WriteVerbose("Rule dummy was not in cache: compiling"); | ||
logger.Received(2).WriteVerbose("Rule dummy found in cache"); | ||
} | ||
|
||
[Fact, Priority(1)] | ||
public void GivenARule_WhenTheRuleChanges_ThenTheLogger_LogsThatWasNotFoundInCache() | ||
{ | ||
//Given | ||
var logger = Substitute.For<IAggregatorLogger>(); | ||
string ruleName = "dummy"; | ||
var ruleCode1 = new[] { "/* v1 */" }; | ||
var ruleCode2 = new[] { "/* v2 */" }; | ||
|
||
//When | ||
_ = new ScriptedRuleWrapper(ruleName, ruleCode1, logger); | ||
_ = new ScriptedRuleWrapper(ruleName, ruleCode2, logger); | ||
_ = new ScriptedRuleWrapper(ruleName, ruleCode2, logger); | ||
|
||
//Then | ||
logger.Received(2).WriteVerbose("Rule dummy was not in cache: compiling"); | ||
logger.Received(1).WriteVerbose("Rule dummy found in cache"); | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters