Ejemplo n.º 1
0
        public void ReadInstanceCount()
        {
            _dataMaintainer.DesigntimeInitialize();
            long testInstanceCount = _dataMaintainer.GetTestInstanceCount(null);

            Assert.AreEqual(2, testInstanceCount);
        }
Ejemplo n.º 2
0
 public void TearDown()
 {
     // 只有DesigntimeInitialize可以删掉记录
     _dataMaintainer.DesigntimeInitialize();
     // 删除记录
     _dataMaintainer.DeleteTestInstance($"RuntimeHash='{_testInstanceData1.RuntimeHash}'");
     _dataMaintainer.DeleteTestInstance($"RuntimeHash='{_testInstanceData2.RuntimeHash}'");
     _resultManager?.Dispose();
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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
        }