Add() public method

public Add ( IDebugItemResult itemToAdd, bool isDeserialize = false ) : void
itemToAdd IDebugItemResult
isDeserialize bool
return void
Exemplo n.º 1
0
 public void Contains_With_InvalidFilter_Expected_ReturnsInstance()
 {
     var item = new DebugItem();
     item.Add(new DebugItemResult { GroupName = "Hello", Value = "world" });
     var result = item.Contains("the");
     Assert.IsFalse(result);
 }
Exemplo n.º 2
0
 public void Contains_With_EmptyFilter_Expected_ReturnsInstance()
 {
     var item = new DebugItem();
     item.Add(new DebugItemResult { GroupName = "Hello", Value = "world" });
     var result = item.Contains(string.Empty);
     Assert.IsTrue(result);
 }
Exemplo n.º 3
0
 public void Constructor_With_Array_Expected_InitializesWithArray()
 {
     var result = new DebugItemResult { GroupName = "Hello", Value = "world" };
     var item = new DebugItem();
     item.Add(result);
     Assert.AreEqual(1, item.FetchResultsList().Count);
     Assert.AreSame(result, item.FetchResultsList()[0]);
 }
Exemplo n.º 4
0
 private static void CreateDebugState(string result, string workflowName, string taskName)
 {
     string user = Thread.CurrentPrincipal.Identity.Name.Replace("\\", "-");
     var state = new DebugState
         {
             HasError = true,
             ID = Guid.NewGuid(),
             Message = string.Format("{0}", result),
             StartTime = DateTime.Now,
             EndTime = DateTime.Now,
             ErrorMessage = string.Format("{0}", result),
             DisplayName = workflowName
         };
     var debug = new DebugItem();
     debug.Add(new DebugItemResult
     {
         Type = DebugItemResultType.Label,
         Value = "Warewolf Execution Error:",
         Label = "Scheduler Execution Error",
         Variable = result
     });
     var js = new Dev2JsonSerializer();
     Thread.Sleep(5000);
     string correlation = GetCorrelationId(WarewolfTaskSchedulerPath + taskName);
     if (!Directory.Exists(OutputPath))
         Directory.CreateDirectory(OutputPath);
     File.WriteAllText(
         string.Format("{0}DebugItems_{1}_{2}_{3}_{4}.txt", OutputPath, workflowName.Replace("\\","_"),
                       DateTime.Now.ToString("yyyy-MM-dd"), correlation, user),
         js.SerializeToBuilder(new List<DebugState> { state }).ToString());
 }
        // ReSharper disable InconsistentNaming - Unit Test
        public void Serialized_Expected_CanBeDeserialized()
        // ReSharper restore InconsistentNaming
        {
            var rw = new MockByteReaderWriter();

            var debugStateIn = DebugStateIn();

            DebugItem itemToAdd = new DebugItem();
            itemToAdd.Add(new DebugItemResult { GroupIndex = 0, GroupName = "Group1", Type = DebugItemResultType.Label, Value = "MyLabel" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 0, GroupName = "Group1", Type = DebugItemResultType.Variable, Value = "[[MyVar]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 0, GroupName = "Group1", Type = DebugItemResultType.Value, Value = "MyValue" });
            debugStateIn.Inputs.Add(itemToAdd);

            debugStateIn.Write(rw);
            var debugStateOut = new DebugState(rw);

            Assert.AreEqual(debugStateIn.WorkspaceID, debugStateOut.WorkspaceID);
            Assert.AreEqual(debugStateIn.ID, debugStateOut.ID);
            Assert.AreEqual(debugStateIn.ParentID, debugStateOut.ParentID);
            Assert.AreEqual(debugStateIn.StateType, debugStateOut.StateType);
            Assert.AreEqual(debugStateIn.DisplayName, debugStateOut.DisplayName);
            Assert.AreEqual(debugStateIn.Name, debugStateOut.Name);
            Assert.AreEqual(debugStateIn.ActivityType, debugStateOut.ActivityType);
            Assert.AreEqual(debugStateIn.Version, debugStateOut.Version);
            Assert.AreEqual(debugStateIn.IsSimulation, debugStateOut.IsSimulation);
            Assert.AreEqual(debugStateIn.HasError, debugStateOut.HasError);
            Assert.AreEqual(debugStateIn.ErrorMessage, debugStateOut.ErrorMessage);
            Assert.AreEqual(debugStateIn.Server, debugStateOut.Server);
            Assert.AreEqual(debugStateIn.Server, debugStateOut.Server);
            Assert.AreEqual(debugStateIn.ServerID, debugStateOut.ServerID);
            Assert.AreEqual(debugStateIn.StartTime, debugStateOut.StartTime);
            Assert.AreEqual(debugStateIn.EndTime, debugStateOut.EndTime);
            Assert.AreEqual(debugStateIn.SessionID, debugStateOut.SessionID);

            Assert.IsTrue(debugStateOut.Inputs[0].FetchResultsList().SequenceEqual(debugStateIn.Inputs[0].FetchResultsList(), new DebugItemResultEqualityComparer()));
        }
        public void DebugItem_Add_GroupIndexIsGreaterThan10_MoreLinkHasData()
        {
            DebugItem itemToAdd = new DebugItem();
            itemToAdd.Add(new DebugItemResult { GroupIndex = 1, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "1", Type = DebugItemResultType.Variable, Variable = "[[record(1).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 2, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "2", Type = DebugItemResultType.Variable, Variable = "[[record(2).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 3, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "3", Type = DebugItemResultType.Variable, Variable = "[[record(3).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 4, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "4", Type = DebugItemResultType.Variable, Variable = "[[record(4).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 5, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "5", Type = DebugItemResultType.Variable, Variable = "[[record(5).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 6, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "6", Type = DebugItemResultType.Variable, Variable = "[[record(6).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 7, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "7", Type = DebugItemResultType.Variable, Variable = "[[record(7).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 8, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "8", Type = DebugItemResultType.Variable, Variable = "[[record(8).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 9, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "9", Type = DebugItemResultType.Variable, Variable = "[[record(9).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 10, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "10", Type = DebugItemResultType.Variable, Variable = "[[record(10).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 11, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "11", Type = DebugItemResultType.Variable, Variable = "[[record(11).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 12, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "12", Type = DebugItemResultType.Variable, Variable = "[[record(12).row]]" });
            itemToAdd.Add(new DebugItemResult { GroupIndex = 12, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "13", Type = DebugItemResultType.Variable, Variable = "[[record(13).row]]" });

            Assert.AreEqual(11, itemToAdd.ResultsList.Count);

            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[0].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[1].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[2].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[3].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[4].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[5].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[6].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[7].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[8].MoreLink));
            Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[9].MoreLink));
            Assert.IsFalse(string.IsNullOrEmpty(itemToAdd.ResultsList[10].MoreLink));
        }
Exemplo n.º 7
0
 public void Contains_With_Filter_Expected_IsCaseInsensitive()
 {
     var item = new DebugItem();
     item.Add(new DebugItemResult { GroupName = "Hello", Value = "world" });
     var result = item.Contains("hel");
     Assert.IsTrue(result);
 }
        public void Filter_Where_ContentIsDebugState_And_FilterTextMatchesOuputOnValue_Expected_True()
        {
            var debugState = new DebugState();
            DebugItem itemToAdd = new DebugItem();
            itemToAdd.Add(new DebugItemResult { Type = DebugItemResultType.Variable, Value = "cake" });
            debugState.Outputs.Add(itemToAdd);

            const bool Expected = true;
            var actual = _debugOutputFilterStrategy.Filter(debugState, "ak");

            Assert.AreEqual(Expected, actual);
        }