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 IStack Stack { get { return this.interpreter.NameStack; } } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ExpressionTest")] [TestCategory("NameExpressionTest")] public void TestRand() { this.interpreter.Run(new NameRandExpression()); Assert.IsTrue(this.interpreter.NameStack.Count == 1); this.CheckOtherStacksAreEmpty(); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ExpressionTest")] [TestCategory("NameExpressionTest")] public void TestRandomBound() { this.interpreter.CustomExpressions.Add("c1", new CodeNoopExpression()); this.interpreter.CustomExpressions.Add("c2", new CodeNoopExpression()); this.interpreter.CustomExpressions.Add("c3", new CodeNoopExpression()); this.interpreter.Run(new NameRandBoundNameExpression()); Assert.IsTrue(this.interpreter.CustomExpressions.Keys.Contains(this.interpreter.NameStack.Top)); this.CheckOtherStacksAreEmpty(); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ExpressionTest")] [TestCategory("NameExpressionTest")] public void TestRandomBoundWithInsufficientArguments() { this.TestWithInsufficientArguments("RANDBOUNDNAME"); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ExpressionTest")] [TestCategory("NameExpressionTest")] public void TestQuote() { this.interpreter.Run(new NameQuoteExpression()); Assert.IsTrue(this.interpreter.IsNameQuoteFlagSet); this.TestStackCounts(); } protected override string[] GetValues(int count) { var ng = new NameGenerator(); var values = new string[count]; for (var i = 0; i < count; i++) values[i] = ng.GetNext(); return values; } protected override void CheckOtherStacksAreEmpty() { this.TestStackCounts(nameStack: null); } } }