using System; using System.Collections.Generic; using System.Text; using UnitTestSharp; using Sunweaver.Commands; using Sunweaver.Commands.BinaryMath; using Sunweaver.Commands.Abstracts; using Sunweaver.DataPrototypes; namespace Sunweaver.UnitTests { public class CoduleTests : TestFixture { Codule codule; public override void TestSetup() { List dna = new List(); dna.Add(new Constant(10)); dna.Add(new Constant(20)); dna.Add(new add()); codule = new Codule(dna); } public void ExecutesRight() { VirtualMachine VM = new VirtualMachine(); codule.Execute(VM); CheckEqual(1, VM.Stack.Count()); CheckEqual(30, VM.Stack.Pop()); } public void stop() { codule.BasePairs.Add(new stop()); codule.BasePairs.Add(new Constant(10)); codule.BasePairs.Add(new Constant(20)); codule.BasePairs.Add(new add()); codule.BasePairs.Add(new add()); VirtualMachine VM = new VirtualMachine(); codule.Execute(VM); CheckEqual(30, VM.Stack.Pop()); } public void start() { codule.BasePairs.Add(new stop()); codule.BasePairs.Add(new start()); codule.BasePairs.Add(new Constant(10)); VirtualMachine VM = new VirtualMachine(); codule.Execute(VM); CheckEqual(10, VM.Stack.Pop()); } } }