namespace HeuristicLab.Tests.Interpreter.Expressions { using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions; using HeuristicLab.Problems.ProgramSynthesis.Push.Generators; using HeuristicLab.Problems.ProgramSynthesis.Push.Stack; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class NameExpressionTests : CommonTests { protected override string TypeName { get { return "NAME"; } } protected override IPushStack Stack { get { return interpreter.NameStack; } } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ExpressionTest")] [TestCategory("NameExpressionTest")] public void TestRand() { configuration.ErcOptions.NameErcOptions.IsEnabled = true; interpreter.Run(new NameRandExpression()); Assert.IsTrue(interpreter.NameStack.Count == 1); CheckOtherStacksAreEmpty(); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ExpressionTest")] [TestCategory("NameExpressionTest")] public void TestRandomBound() { interpreter.CustomExpressions.Add("c1", new CodeNoopExpression()); interpreter.CustomExpressions.Add("c2", new CodeNoopExpression()); interpreter.CustomExpressions.Add("c3", new CodeNoopExpression()); interpreter.Run(new NameRandBoundNameExpression()); Assert.IsTrue(interpreter.CustomExpressions.Keys.Contains(interpreter.NameStack.Top)); CheckOtherStacksAreEmpty(); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ExpressionTest")] [TestCategory("NameExpressionTest")] public void TestRandomBoundWithInsufficientArguments() { TestWithInsufficientArguments("RANDBOUNDNAME"); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ExpressionTest")] [TestCategory("NameExpressionTest")] public void TestQuote() { interpreter.Run(new NameQuoteExpression()); Assert.IsTrue(interpreter.IsNameQuoteFlagSet); TestStackCounts(); } protected override string[] GetValues(int count) { var ng = new StringGenerator(); var values = new string[count]; for (var i = 0; i < count; i++) values[i] = ng.GetNext(); return values; } protected override void CheckOtherStacksAreEmpty() { TestStackCounts(nameStack: null); } } }