using System; using System.Collections.Generic; using System.Text; using UnitTestSharp; using Sunweaver.Commands.Abstracts; using Sunweaver.Commands; using Sunweaver.VM; namespace Sunweaver.UnitTesting.Commands { public class ExplicitStoreTests : TestFixture { BasePair bp; VirtualMachine VM; public override void TestSetup() { VM = new VirtualMachine(); bp = new Sunweaver.Commands.ExplicitStore("test", 36); } public void StoresCorrectly() { VM.Stack.Push(25); bp.Implementation(VM); CheckEqual((short)25, VM.Memory[36]); } public void NameTest() { CheckEqual(".test", bp.ToString()); } public void NegativeLocation() { BasePair temp = new Sunweaver.Commands.ExplicitStore("test", -36); VM.Stack.Push(25); temp.Implementation(VM); CheckEqual((short)25, VM.Memory[36]); } public void OverflowValue() { VM.Stack.Push(2500001); bp.Implementation(VM); CheckEqual((short)1, VM.Memory[36]); } public void OverflowLocation() { BasePair temp = new Sunweaver.Commands.ExplicitStore("test", 1001); VM.Stack.Push(25); temp.Implementation(VM); CheckEqual((short)25, VM.Memory[1]); } public void AbortsWhenFalse() { VM.BoolStack.Push(false); VM.Stack.Push(25); bp.Implementation(VM); CheckEqual((short)0, VM.Memory[36]); } } }