public void It_Should_Write_And_Read_A_Script_Dynamic_Data()
            {
                var scriptDynamicData = new ScriptDynamicDataModel
                {
                    Key     = "test-script-1",
                    LastRun = DateTime.UtcNow.Ticks
                };

                var result = _scriptsDynamicDataRepository.GetAll();

                Assert.IsNotNull(result);
                Assert.AreEqual(0, result.Count());

                //Create
                _scriptsDynamicDataRepository.Set(scriptDynamicData);

                result = _scriptsDynamicDataRepository.GetAll();
                Assert.IsNotNull(result);
                Assert.AreEqual(1, result.Count());
                Assert.AreEqual(scriptDynamicData.Key, result.First().Key);
                Assert.AreEqual(scriptDynamicData.LastRun, result.First().LastRun);

                //Update
                scriptDynamicData.LastRun += 100;
                _scriptsDynamicDataRepository.Set(scriptDynamicData);

                result = _scriptsDynamicDataRepository.GetAll();
                Assert.IsNotNull(result);
                Assert.AreEqual(1, result.Count());
                Assert.AreEqual(scriptDynamicData.Key, result.First().Key);
                Assert.AreEqual(scriptDynamicData.LastRun, result.First().LastRun);
            }
Exemplo n.º 2
0
        private double GetElapsedDelayFromScriptLastRun(ScriptModel targetScript)
        {
            var scriptDynamicData = _scriptsDynamicDataRepository.GetAll()
                                    .FirstOrDefault(script => script.Key == targetScript.Key);
            var lastRun = scriptDynamicData != null ? scriptDynamicData.LastRun : 0;

            return(TimeSpan.FromTicks(DateTime.UtcNow.Ticks - lastRun).TotalSeconds);
        }