Exemple #1
0
    private ExecutedCodeProperties CallCsharpExecuter(ProgramProperties programProperties,
                                                      ExecutedCodeProperties executedCodeProperties)
    {
        CsharpCodeExecuter csharpCodeExecuter = new CsharpCodeExecuter(programProperties, _excecutedCodeProperties);
        CodeExecuter       codeExecuter       = new CodeExecuter(csharpCodeExecuter);

        return(codeExecuter.Execute());
    }
Exemple #2
0
        public void ExecuteCode_正常系()
        {
            var executer = new CodeExecuter();
            var p        = new PrivateObject(executer);

            //現在時点で3回足す
            executer.ExecuteCode("+++");
            var array = (int[])p.GetField("_pointer");

            Assert.AreEqual(3, array[0]);
        }
Exemple #3
0
        public void IsPointerValueZero_正常系()
        {
            var executer = new CodeExecuter();
            var p        = new PrivateObject(executer);

            p.SetField("_pointer", new int[] { 0, 1 });

            p.SetField("_pointerPosition", 0);
            Assert.AreEqual(true, (bool)p.Invoke("IsPointerValueZero"));

            p.SetField("_pointerPosition", 1);
            Assert.AreEqual(false, (bool)p.Invoke("IsPointerValueZero"));
        }
Exemple #4
0
        public void PlusMinusPointerValue_正常系()
        {
            var executer        = new CodeExecuter();
            var p               = new PrivateObject(executer);
            var pointerPosition = (int)p.GetField("_pointerPosition");
            var pointerArray    = (int[])p.GetField("_pointer");

            //ポインターの値を変える
            p.Invoke("PlusMinusPointerValue", new object[] { 1 });
            Assert.AreEqual(1, pointerArray[0]);

            p.Invoke("PlusMinusPointerValue", new object[] { -1 });
            Assert.AreEqual(0, pointerArray[0]);
        }
Exemple #5
0
        public string Execute(string code)
        {
            var engine = new CodeExecuter();

            try
            {
                var unformatted = engine.Execute(code);

                return(FormatResult(unformatted));
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("RossieEngineService", ex.ToString(), EventLogEntryType.Error);
            }

            return(string.Empty);
        }
Exemple #6
0
        public void MovePointer_正常系()
        {
            var executer        = new CodeExecuter();
            var p               = new PrivateObject(executer);
            var pointerPosition = (int)p.GetField("_pointerPosition");
            var pointerArray    = (int[])p.GetField("_pointer");

            //ポインターを動かす
            p.Invoke("MovePointer", new object[] { 1 });

            pointerPosition = (int)p.GetField("_pointerPosition");
            pointerArray    = (int[])p.GetField("_pointer");

            Assert.AreEqual(1, pointerPosition);

            pointerPosition = (int)p.GetField("_pointerPosition");
            pointerArray    = (int[])p.GetField("_pointer");

            //ポインターを表す配列の数値が変動する
            Assert.AreEqual(2, pointerArray.Length);

            p.Invoke("MovePointer", new object[] { -1 });

            pointerPosition = (int)p.GetField("_pointerPosition");
            pointerArray    = (int[])p.GetField("_pointer");

            Assert.AreEqual(0, pointerPosition);

            p.Invoke("MovePointer", new object[] { -1 });

            pointerPosition = (int)p.GetField("_pointerPosition");
            pointerArray    = (int[])p.GetField("_pointer");

            Assert.AreEqual(0, pointerPosition);
            //ポインターを表す配列の数値が変動する
            Assert.AreEqual(3, pointerArray.Length);
        }
Exemple #7
0
 public MainWindow()
 {
     InitializeComponent();
     _codeExecuter = new CodeExecuter();
 }