public virtual void AddData(RuntimeStatusData runtimeStatus) { Dictionary <string, string> columnToValue = DataModelMapper.GetColumnValueMapping(runtimeStatus); string cmd = SqlCommandFactory.CreateInsertCmd(DataBaseItemNames.StatusTableName, columnToValue); ExecuteWriteCommand(cmd); }
public void ReadRuntimeStatus() { _dataMaintainer.DesigntimeInitialize(); IList <RuntimeStatusData> statusDatas = _dataMaintainer.GetRuntimeStatus(_sessionResultData11.RuntimeHash, _sessionResultData11.Session); Assert.IsTrue(AreEqauls(_runtimeStatusData1111, statusDatas[0])); Assert.IsTrue(AreEqauls(_runtimeStatusData1112, statusDatas[1])); statusDatas = _dataMaintainer.GetRuntimeStatus(_sessionResultData12.RuntimeHash, _sessionResultData12.Session); Assert.IsTrue(AreEqauls(_runtimeStatusData1211, statusDatas[0])); Assert.IsTrue(AreEqauls(_runtimeStatusData1212, statusDatas[1])); statusDatas = _dataMaintainer.GetRuntimeStatus(_sessionResultData21.RuntimeHash, _sessionResultData21.Session); Assert.IsTrue(AreEqauls(_runtimeStatusData2111, statusDatas[0])); Assert.IsTrue(AreEqauls(_runtimeStatusData2112, statusDatas[1])); statusDatas = _dataMaintainer.GetRuntimeStatus(_sessionResultData22.RuntimeHash, _sessionResultData22.Session); Assert.IsTrue(AreEqauls(_runtimeStatusData2211, statusDatas[0])); Assert.IsTrue(AreEqauls(_runtimeStatusData2212, statusDatas[1])); RuntimeStatusData statusData = _dataMaintainer.GetRuntimeStatusByIndex(_runtimeStatusData1111.RuntimeHash, _runtimeStatusData1111.StatusIndex); Assert.IsTrue(AreEqauls(_runtimeStatusData1111, statusData)); statusData = _dataMaintainer.GetRuntimeStatusByIndex(_runtimeStatusData1112.RuntimeHash, _runtimeStatusData1112.StatusIndex); Assert.IsTrue(AreEqauls(_runtimeStatusData1112, statusData)); statusData = _dataMaintainer.GetRuntimeStatusByIndex(_runtimeStatusData1211.RuntimeHash, _runtimeStatusData1211.StatusIndex); Assert.IsTrue(AreEqauls(_runtimeStatusData1211, statusData)); statusData = _dataMaintainer.GetRuntimeStatusByIndex(_runtimeStatusData1212.RuntimeHash, _runtimeStatusData1212.StatusIndex); Assert.IsTrue(AreEqauls(_runtimeStatusData1212, statusData)); statusData = _dataMaintainer.GetRuntimeStatusByIndex(_runtimeStatusData2111.RuntimeHash, _runtimeStatusData2111.StatusIndex); Assert.IsTrue(AreEqauls(_runtimeStatusData2111, statusData)); statusData = _dataMaintainer.GetRuntimeStatusByIndex(_runtimeStatusData2211.RuntimeHash, _runtimeStatusData2211.StatusIndex); Assert.IsTrue(AreEqauls(_runtimeStatusData2211, statusData)); statusData = _dataMaintainer.GetRuntimeStatusByIndex(_runtimeStatusData2211.RuntimeHash, _runtimeStatusData2211.StatusIndex); Assert.IsTrue(AreEqauls(_runtimeStatusData2211, statusData)); statusData = _dataMaintainer.GetRuntimeStatusByIndex(_runtimeStatusData2212.RuntimeHash, _runtimeStatusData2212.StatusIndex); Assert.IsTrue(AreEqauls(_runtimeStatusData2212, statusData)); }
public virtual RuntimeStatusData GetRuntimeStatusByIndex(string runtimeHash, long index) { string filter = $"{DataBaseItemNames.RuntimeIdColumn}='{runtimeHash}' AND {DataBaseItemNames.StatusIndexColumn}={index}"; string cmd = SqlCommandFactory.CreateQueryCmd(filter, DataBaseItemNames.StatusTableName); RuntimeStatusData statusData = null; using (DbDataReader dataReader = ExecuteReadCommand(cmd)) { while (dataReader.Read()) { statusData = new RuntimeStatusData(); DataModelMapper.ReadToObject(dataReader, statusData); } } return(statusData); }
private RuntimeStatusData CreateRuntimeStatusData(int instanceId, int sessionid, int sequence, int dataIndex) { RuntimeStatusData runtimeStatusData = new RuntimeStatusData() { RuntimeHash = $"RuntimeHash{instanceId}", Session = sessionid, Sequence = sequence, StatusIndex = dataIndex, Time = DateTime.Now, Result = StepResult.Pass, ElapsedTime = 10000, Stack = "", WatchData = "" }; return(runtimeStatusData); }
public IList <RuntimeStatusData> GetRuntimeStatus(string runtimeHash, int session, int sequenceIndex) { string filter = $"{DataBaseItemNames.RuntimeIdColumn}='{runtimeHash}' AND {DataBaseItemNames.SessionIdColumn}={session} AND {DataBaseItemNames.SequenceIndexColumn}={sequenceIndex}"; string cmd = SqlCommandFactory.CreateQueryCmdWithOrder(filter, DataBaseItemNames.StatusTableName, DataBaseItemNames.StatusIndexColumn); List <RuntimeStatusData> statusDatas = new List <RuntimeStatusData>(500); using (DbDataReader dataReader = ExecuteReadCommand(cmd)) { while (dataReader.Read()) { RuntimeStatusData runtimeStatusData = new RuntimeStatusData(); DataModelMapper.ReadToObject(dataReader, runtimeStatusData); statusDatas.Add(runtimeStatusData); } } return(statusDatas); }
public SequenceStateHandle(int session, ISequence sequence, StateManageContext stateManageContext) { this.Session = session; this._sequence = sequence; this.SequenceIndex = sequence.Index; this.State = RuntimeState.Idle; this._eventDispatcher = stateManageContext.EventDispatcher; this._stateManageContext = stateManageContext; this.BlockedTime = TimeSpan.Zero; this._blockedStart = DateTime.MaxValue; this.RunStack = CallStack.GetEmptyStack(session, sequence.Index); _sequenceTestResult = this._stateManageContext.GetSequenceResults(Session, SequenceIndex); _sequenceResultData = new SequenceResultData() { Name = sequence.Name, Description = sequence.Description, StartTime = DateTime.MaxValue, EndTime = DateTime.MaxValue, CoroutineId = -1, ElapsedTime = 0, RuntimeHash = stateManageContext.RuntimeHash, FailInfo = null, Result = RuntimeState.Idle, FailStack = null, Session = session, SequenceIndex = sequence.Index, }; _stateManageContext.DatabaseProxy.WriteData(_sequenceResultData); _statusData = new RuntimeStatusData() { RuntimeHash = _stateManageContext.RuntimeHash, Sequence = this.SequenceIndex, Session = Session, Stack = string.Empty, Time = CurrentTime, ElapsedTime = this.ElapsedTime.TotalMilliseconds, Result = StepResult.NotAvailable, WatchData = null, StatusIndex = -1 }; }
public IList <RuntimeStatusData> GetRuntimeStatusInRange(string runtimeHash, int session, long startIndex, long count) { string filter = $"{DataBaseItemNames.RuntimeIdColumn}='{runtimeHash}' AND {DataBaseItemNames.SessionIdColumn}={session} AND {DataBaseItemNames.StatusIndexColumn} >= {startIndex}"; string cmd = SqlCommandFactory.CreateQueryCmdWithOrder(filter, DataBaseItemNames.StatusTableName, DataBaseItemNames.StatusIndexColumn); if (count > 0) { cmd += $" LIMIT {count}"; } List <RuntimeStatusData> statusDatas = new List <RuntimeStatusData>(500); using (DbDataReader dataReader = ExecuteReadCommand(cmd)) { while (dataReader.Read()) { RuntimeStatusData runtimeStatusData = new RuntimeStatusData(); DataModelMapper.ReadToObject(dataReader, runtimeStatusData); statusDatas.Add(runtimeStatusData); } } statusDatas.TrimExcess(); return(statusDatas); }
public void WriteData(RuntimeStatusData status) { _dataMaintainer.AddData(status); }
public void WriteData(RuntimeStatusData status) { // TODO }
public DataMaintainTest() { Type runnerType = typeof(TestflowRunner); TestflowRunnerOptions option = new TestflowRunnerOptions(); FakeTestflowRunner fakeTestflowRunner = new FakeTestflowRunner(option); Type intType = typeof(int); FieldInfo fieldInfo = runnerType.GetField("_runnerInst", BindingFlags.Static | BindingFlags.NonPublic); fieldInfo.SetValue(null, fakeTestflowRunner); fakeTestflowRunner.SetLogService(null); _dataMaintainer = new DataMaintainer.DataMaintainer(); ModuleConfigData moduleConfigData = new ModuleConfigData(); moduleConfigData.InitExtendProperties(); _dataMaintainer.ApplyConfig(moduleConfigData); _testInstanceData1 = CreateTestInstance(1); _sessionResultData11 = CreateSessionResult(1, 1); _sequenceResultData111 = CreateSequenceResult(1, 1, 1); _sequenceResultData112 = CreateSequenceResult(1, 1, 2); _runtimeStatusData1111 = CreateRuntimeStatusData(1, 1, 1, 1); _runtimeStatusData1112 = CreateRuntimeStatusData(1, 1, 2, 2); _sessionResultData12 = CreateSessionResult(1, 2); _sequenceResultData121 = CreateSequenceResult(1, 2, 1); _sequenceResultData122 = CreateSequenceResult(1, 2, 2); _runtimeStatusData1211 = CreateRuntimeStatusData(1, 2, 1, 3); _runtimeStatusData1212 = CreateRuntimeStatusData(1, 2, 2, 4); _performanceStatus111 = CreatePerformanceData(1, 1, 1); _performanceStatus112 = CreatePerformanceData(1, 1, 2); _performanceStatus121 = CreatePerformanceData(1, 2, 3); _performanceStatus122 = CreatePerformanceData(1, 2, 4); _testInstanceData2 = CreateTestInstance(2); _sessionResultData21 = CreateSessionResult(2, 1); _sequenceResultData211 = CreateSequenceResult(2, 1, 1); _sequenceResultData212 = CreateSequenceResult(2, 1, 2); _runtimeStatusData2111 = CreateRuntimeStatusData(2, 1, 1, 1); _runtimeStatusData2112 = CreateRuntimeStatusData(2, 1, 2, 2); _sessionResultData22 = CreateSessionResult(2, 2); _sequenceResultData221 = CreateSequenceResult(2, 2, 1); _sequenceResultData222 = CreateSequenceResult(2, 2, 2); _runtimeStatusData2211 = CreateRuntimeStatusData(2, 2, 1, 3); _runtimeStatusData2212 = CreateRuntimeStatusData(2, 2, 2, 4); _performanceStatus211 = CreatePerformanceData(2, 1, 1); _performanceStatus212 = CreatePerformanceData(2, 1, 2); _performanceStatus221 = CreatePerformanceData(2, 2, 3); _performanceStatus222 = CreatePerformanceData(2, 2, 4); // 只有DesigntimeInitialize可以删掉记录 _dataMaintainer.DesigntimeInitialize(); // 删除记录 _dataMaintainer.DeleteTestInstance($"RuntimeHash='{_testInstanceData1.RuntimeHash}'"); _dataMaintainer.DeleteTestInstance($"RuntimeHash='{_testInstanceData2.RuntimeHash}'"); // 只有RuntimeInitialize可以新增记录 _dataMaintainer.RuntimeInitialize(); _dataMaintainer.AddData(_testInstanceData1); _dataMaintainer.AddData(_sessionResultData11); _dataMaintainer.AddData(_sequenceResultData111); _dataMaintainer.AddData(_sequenceResultData112); _dataMaintainer.AddData(_sessionResultData12); _dataMaintainer.AddData(_sequenceResultData121); _dataMaintainer.AddData(_sequenceResultData122); _dataMaintainer.AddData(_runtimeStatusData1211); _dataMaintainer.AddData(_runtimeStatusData1212); _dataMaintainer.AddData(_runtimeStatusData1111); _dataMaintainer.AddData(_runtimeStatusData1112); _dataMaintainer.AddData(_performanceStatus111); _dataMaintainer.AddData(_performanceStatus112); _dataMaintainer.AddData(_performanceStatus121); _dataMaintainer.AddData(_performanceStatus122); _dataMaintainer.AddData(_testInstanceData2); _dataMaintainer.AddData(_sessionResultData21); _dataMaintainer.AddData(_sequenceResultData211); _dataMaintainer.AddData(_sequenceResultData212); _dataMaintainer.AddData(_sessionResultData22); _dataMaintainer.AddData(_sequenceResultData221); _dataMaintainer.AddData(_sequenceResultData222); _dataMaintainer.AddData(_runtimeStatusData2211); _dataMaintainer.AddData(_runtimeStatusData2212); _dataMaintainer.AddData(_runtimeStatusData2111); _dataMaintainer.AddData(_runtimeStatusData2112); _dataMaintainer.AddData(_performanceStatus211); _dataMaintainer.AddData(_performanceStatus212); _dataMaintainer.AddData(_performanceStatus221); _dataMaintainer.AddData(_performanceStatus222); }
public void AddData(RuntimeStatusData runtimeStatus) { _databaseProxy.AddData(runtimeStatus); }
public ResultManagerTest() { #region 创建并初始化假的TestFlowRunner, 将创建的DataMaintainer赋予它 Type runnerType = typeof(TestflowRunner); //默认options TestflowRunnerOptions option = new TestflowRunnerOptions(); //创建假的TestFlowRunner FakeTestflowRunner fakeTestflowRunner = new FakeTestflowRunner(option); Type intType = typeof(int); //用反射将获取private fieldInfo,然后赋值fake FieldInfo fieldInfo = runnerType.GetField("_runnerInst", BindingFlags.Static | BindingFlags.NonPublic); fieldInfo.SetValue(null, fakeTestflowRunner); _dataMaintainer = new DataMaintainer.DataMaintainer(); fakeTestflowRunner.SetDataMaintainer(_dataMaintainer); fakeTestflowRunner.Initialize(); #endregion _resultManager = new ResultManager.ResultManager(); #region 用此类里的方法创建测试用数据 _testInstanceData1 = CreateTestInstance(1); _sessionResultData11 = CreateSessionResult(1, 1); _sequenceResultData111 = CreateSequenceResult(1, 1, 1); _sequenceResultData112 = CreateSequenceResult(1, 1, 2); _runtimeStatusData1111 = CreateRuntimeStatusData(1, 1, 1, 1); _runtimeStatusData1112 = CreateRuntimeStatusData(1, 1, 2, 2); _sessionResultData12 = CreateSessionResult(1, 2); _sequenceResultData121 = CreateSequenceResult(1, 2, 1); _sequenceResultData122 = CreateSequenceResult(1, 2, 2); _runtimeStatusData1211 = CreateRuntimeStatusData(1, 2, 1, 3); _runtimeStatusData1212 = CreateRuntimeStatusData(1, 2, 2, 4); _performanceStatus111 = CreatePerformanceData(1, 1, 1); _performanceStatus112 = CreatePerformanceData(1, 1, 2); _performanceStatus121 = CreatePerformanceData(1, 2, 3); _performanceStatus122 = CreatePerformanceData(1, 2, 4); _testInstanceData2 = CreateTestInstance(2); _sessionResultData21 = CreateSessionResult(2, 1); _sequenceResultData211 = CreateSequenceResult(2, 1, 1); _sequenceResultData212 = CreateSequenceResult(2, 1, 2); _runtimeStatusData2111 = CreateRuntimeStatusData(2, 1, 1, 1); _runtimeStatusData2112 = CreateRuntimeStatusData(2, 1, 2, 2); _sessionResultData22 = CreateSessionResult(2, 2); _sequenceResultData221 = CreateSequenceResult(2, 2, 1); _sequenceResultData222 = CreateSequenceResult(2, 2, 2); _runtimeStatusData2211 = CreateRuntimeStatusData(2, 2, 1, 3); _runtimeStatusData2212 = CreateRuntimeStatusData(2, 2, 2, 4); _performanceStatus211 = CreatePerformanceData(2, 1, 1); _performanceStatus212 = CreatePerformanceData(2, 1, 2); _performanceStatus221 = CreatePerformanceData(2, 2, 3); _performanceStatus222 = CreatePerformanceData(2, 2, 4); #endregion #region 初始化_dataMaintainer // 只有DesigntimeInitialize可以删掉记录 _dataMaintainer.DesigntimeInitialize(); // 删除记录 _dataMaintainer.DeleteTestInstance($"RuntimeHash='{_testInstanceData1.RuntimeHash}'"); _dataMaintainer.DeleteTestInstance($"RuntimeHash='{_testInstanceData2.RuntimeHash}'"); // 只有RuntimeInitialize可以新增记录 _dataMaintainer.RuntimeInitialize(); #endregion #region 添加数据到数据库 _dataMaintainer.AddData(_testInstanceData1); _dataMaintainer.AddData(_sessionResultData11); _dataMaintainer.AddData(_sequenceResultData111); _dataMaintainer.AddData(_sequenceResultData112); _dataMaintainer.AddData(_sessionResultData12); _dataMaintainer.AddData(_sequenceResultData121); _dataMaintainer.AddData(_sequenceResultData122); _dataMaintainer.AddData(_runtimeStatusData1211); _dataMaintainer.AddData(_runtimeStatusData1212); _dataMaintainer.AddData(_runtimeStatusData1111); _dataMaintainer.AddData(_runtimeStatusData1112); _dataMaintainer.AddData(_performanceStatus111); _dataMaintainer.AddData(_performanceStatus112); _dataMaintainer.AddData(_performanceStatus121); _dataMaintainer.AddData(_performanceStatus122); _dataMaintainer.AddData(_testInstanceData2); _dataMaintainer.AddData(_sessionResultData21); _dataMaintainer.AddData(_sequenceResultData211); _dataMaintainer.AddData(_sequenceResultData212); _dataMaintainer.AddData(_sessionResultData22); _dataMaintainer.AddData(_sequenceResultData221); _dataMaintainer.AddData(_sequenceResultData222); _dataMaintainer.AddData(_runtimeStatusData2211); _dataMaintainer.AddData(_runtimeStatusData2212); _dataMaintainer.AddData(_runtimeStatusData2111); _dataMaintainer.AddData(_runtimeStatusData2112); _dataMaintainer.AddData(_performanceStatus211); _dataMaintainer.AddData(_performanceStatus212); _dataMaintainer.AddData(_performanceStatus221); _dataMaintainer.AddData(_performanceStatus222); #endregion }
public override void AddData(RuntimeStatusData runtimeStatus) { throw new System.InvalidOperationException(); }