public void TestTransactionConflict()
        {
            Stm.Init();
            File.WriteAllText(logFileName, string.Empty);
            var variable_1 = new StmMemory <int>();
            var variable_2 = new StmMemory <int>();

            File.WriteAllText("Log.txt", string.Empty);
            List <Action> actions = new List <Action>()
            {
                new Action(() => {
                    Stm.Do(new TransactionalAction((IStmTransaction transaction) => {
                        variable_1.Set(2, transaction);
                        variable_1.Version[0] = 15;
                        variable_2.Set(3, transaction);
                    }), false);
                }),
            };
            List <Task> tasks = new List <Task>();

            foreach (Action action in actions)
            {
                tasks.Add(Task.Run(action));
            }
            foreach (Task task in tasks)
            {
                task.Wait();
            }
            string[] logFileLines = File.ReadAllLines("Log.txt");
            string   lastLogLine  = logFileLines[logFileLines.Length - 2];

            Assert.AreEqual(true, lastLogLine.Contains(I_STM_TRANSACTION_STATE.CONFLICT.ToString()));
        }
        public void TestCorrectSTMWork()
        {
            Stm.Init();
            File.WriteAllText(logFileName, string.Empty);
            var variable_1 = new StmMemory <int>();
            var variable_2 = new StmMemory <int>();

            File.WriteAllText("Log.txt", string.Empty);
            List <Action> actions = new List <Action>()
            {
                new Action(() => {
                    Stm.Do(new TransactionalAction((IStmTransaction transaction) => {
                        variable_1.Set(2, transaction);
                        variable_2.Set(3, transaction);
                    }));
                }),
                new Action(() => {
                    Stm.Do(new TransactionalAction((IStmTransaction transaction) => {
                        variable_1.Set(3, transaction);
                        variable_2.Set(4, transaction);
                    }));
                }),
                new Action(() => {
                    Stm.Do(new TransactionalAction((IStmTransaction transaction) => {
                        variable_1.Get(transaction);
                        variable_2.Get(transaction);
                    }));
                }),
            };
            List <Task> tasks = new List <Task>();

            foreach (Action action in actions)
            {
                tasks.Add(Task.Run(action));
            }
            foreach (Task task in tasks)
            {
                task.Wait();
            }
            List <KeyValuePair <int, TRANSACTION_ACTION> > actionsSequence = GetTransactionActionsSequence();

            TestActionCount(actionsSequence, TRANSACTION_ACTION.COMMIT, 3);
            TestActionCount(actionsSequence, TRANSACTION_ACTION.CONFLICT, 2 + 1, true);
            TestTransactionsActionsSequence(actionsSequence);
        }