コード例 #1
0
        public void TurnOffConditionalAndFlagsDontEmitTest()
        {
            string originalValue = @"lead stuff
//#if (true)
    true stuff
//#else 
    false stuff
//#endif
Entering Conditional processing = off
//-:cnd:noEmit
...in
//#if (true)
    in-conditional true (IF) stuff
//#else
    in-conditional ELSE stuff               
//#endif
...about to exit
//+:cnd:noEmit
After Conditional processing = off
//#if (false)
    After conditional IF(false) stuff
//#else
    After conditional ELSE(true) stuff
//#endif
Final stuff";

            string expectedValue = @"lead stuff
    true stuff
Entering Conditional processing = off
...in
//#if (true)
    in-conditional true (IF) stuff
//#else
    in-conditional ELSE stuff               
//#endif
...about to exit
After Conditional processing = off
    After conditional ELSE(true) stuff
Final stuff";

            VariableCollection vc = new VariableCollection();
            IProcessor         partialProcessor = new ConditionalTests().SetupCStyleWithCommentsProcessor(vc);

            string on        = "//+:cnd";
            string onNoEmit  = on + ":noEmit";
            string off       = "//-:cnd";
            string offNoEmit = off + ":noEmit";
            List <IOperationProvider> flagOperations = new List <IOperationProvider>();

            flagOperations.Add(new SetFlag(Conditional.OperationName, on, off, onNoEmit, offNoEmit, null));

            IProcessor processor = partialProcessor.CloneAndAppendOperations(flagOperations);

            RunAndVerify(originalValue, expectedValue, processor, 9999);
        }
コード例 #2
0
        public void TurnOffConditionalTest()
        {
            string originalValue = @"lead stuff
//#if (true)
    true stuff
//#else 
    false stuff
//#endif
Entering Conditional processing = off
//-:cnd
...in
//#if (true)
    in-conditional true (IF) stuff
//#else
    in-conditional ELSE stuff               
//#endif
...about to exit
//+:cnd
After Conditional processing = off
//#if (false)
    After conditional IF(false) stuff
//#else
    After conditional ELSE(true) stuff
//#endif
Final stuff";

            string expectedValue = @"lead stuff
    true stuff
Entering Conditional processing = off
//-:cnd
...in
//#if (true)
    in-conditional true (IF) stuff
//#else
    in-conditional ELSE stuff               
//#endif
...about to exit
//+:cnd
After Conditional processing = off
    After conditional ELSE(true) stuff
Final stuff";

            VariableCollection vc = new VariableCollection();
            IProcessor         partialProcessor = new ConditionalTests(_environmentSettingsHelper).SetupCStyleWithCommentsProcessor(vc);

            string on  = "//+:cnd";
            string off = "//-:cnd";
            List <IOperationProvider> flagOperations = new List <IOperationProvider>();

            flagOperations.Add(new SetFlag(Conditional.OperationName, on.TokenConfig(), off.TokenConfig(), string.Empty.TokenConfig(), string.Empty.TokenConfig(), null, true));

            IProcessor processor = partialProcessor.CloneAndAppendOperations(flagOperations);

            RunAndVerify(originalValue, expectedValue, processor, 9999);
        }