Inheritance: IDebugItem
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 WriteDebugItems(string workflowName, string taskName, string result)
        {
            string user = Thread.CurrentPrincipal.Identity.Name.Replace("\\", "-");

            var state = new DebugState
            {
                HasError = false,
                ID = Guid.NewGuid(),
                StartTime = DateTime.Now,
                EndTime = DateTime.Now,
                ActivityType = ActivityType.Workflow,
                ExecutingUser = user,
                Server = "localhost",
                ServerID = Guid.Empty,
                DisplayName = workflowName
            };
            if(!string.IsNullOrEmpty(result))
            {
                var data = DataListUtil.AdjustForEncodingIssues(result);
                bool isFragment;
                var isXml = DataListUtil.IsXml(data, out isFragment);
                if(isXml)
                {
                    var xmlData = XElement.Parse(data);
                    var allChildren = xmlData.Elements();
                    var groupedData = allChildren.GroupBy(element => element.Name);

                    var recSets = groupedData as IGrouping<XName, XElement>[] ?? groupedData.ToArray();
                    foreach(var grouping in recSets)
                    {
                        var debugItem = new DebugItem();
                        foreach(var name in grouping)
                        {
                            if(name.HasElements)
                            {
                                var debugItemResult = ProcessRecordSet(name, name.Elements());
                                debugItem.ResultsList.AddRange(debugItemResult);
                            }
                            else
                            {
                                var debugItemResult = new DebugItemResult
                                {
                                    Variable = DataListUtil.AddBracketsToValueIfNotExist(name.Name.LocalName),
                                    Value = name.Value,
                                    Operator = "=",
                                    Type = DebugItemResultType.Variable
                                };
                                debugItem.ResultsList.Add(debugItemResult);
                            }
                        }
                        state.Outputs.Add(debugItem);
                    }
                }
            }
            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());

        }
Exemplo n.º 5
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());
 }
Exemplo n.º 6
0
 public DebugCopyException(string msg, DebugItem item)
     : base(msg)
 {
     Item = item;
 }
        // 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.º 9
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);
 }
Exemplo n.º 10
0
        // ReSharper disable InconsistentNaming - Unit Test
        public void SaveFile_With_Contents_Expected_SavesFileToDisk()
        // ReSharper restore InconsistentNaming
        {
            var debugState = new DebugItem();

            debugState.ClearFile("TestFile.txt");
            EnvironmentVariables.WebServerUri = "http://localhost:3142";
            var uri = debugState.SaveFile(LongText, "TestFile.txt");
            var path = new Uri(uri).OriginalString.Replace("?DebugItemFilePath=", "").Replace(EnvironmentVariables.WebServerUri + "/Services/FetchDebugItemFileService", "");
            var exists = File.Exists(path);
            Assert.IsTrue(exists);

            var contents = File.ReadAllText(path);
            Assert.AreEqual(LongText, contents);
        }
Exemplo n.º 11
0
        // ReSharper disable InconsistentNaming - Unit Test
        public void DebugIem_SaveFile_WithContentsNewLineChars_ExpectedSavesFileToDiskWithCorrectChars()
        // ReSharper restore InconsistentNaming
        {
            var debugState = new DebugItem();

            debugState.ClearFile("TestFile.txt");
            EnvironmentVariables.WebServerUri = "http://localhost:3142";
            string expeced = "\r\nThis is\r\n the text\\n that we are writing";
            string textToWrite = "\nThis is\r\n the text\\n that we are writing";

            var uri = debugState.SaveFile(textToWrite, "TestFile.txt");
            var path = new Uri(uri).OriginalString.Replace("?DebugItemFilePath=", "").Replace(EnvironmentVariables.WebServerUri + "/Services/FetchDebugItemFileService", "");
            var exists = File.Exists(path);
            Assert.IsTrue(exists);

            var contents = File.ReadAllText(path);
            Assert.AreEqual(expeced, contents);
        }
Exemplo n.º 12
0
        // ReSharper disable InconsistentNaming - Unit Test
        public void SaveFile_With_NullParameters_Expected_ThrowsArgumentNullException()
        // ReSharper restore InconsistentNaming
        {
            var debugState = new DebugItem();

            debugState.SaveFile(null, null);
        }
Exemplo n.º 13
0
        // ReSharper disable InconsistentNaming - Unit Test
        public void TryCache_With_ValueGreaterThanMaxCharDispatchCount_Expected_TruncatesValueToActCharDispatchCount()
        // ReSharper restore InconsistentNaming
        {
            var item = CreateDebugItemWithLongValue();

            var debugState = new DebugItem();
            debugState.TryCache(item);

            Assert.AreEqual(DebugItem.ActCharDispatchCount, item.Value.Length);
        }
        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);
        }
        public List<DebugItem> GetDebugInputs(IList<IDev2Definition> inputs, IBinaryDataList dataList, ErrorResultTO errors)
        {
            if(errors == null)
            {
                throw new ArgumentNullException("errors");
            }

            var results = new List<DebugItem>();
            foreach(IDev2Definition dev2Definition in inputs)
            {
                var variableName = GetVariableName(dev2Definition);
                DebugItem itemToAdd = new DebugItem();
                AddDebugItem(new DebugEvalResult(variableName, "", DataObject.Environment), itemToAdd);
                results.Add(itemToAdd);
            }

            foreach(IDebugItem debugInput in results)
            {
                debugInput.FlushStringBuilder();
            }

            return results;
        }
        public List<DebugItem> GetDebugValues(IList<IDev2Definition> values, IDSFDataObject dataObject, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            var results = new List<DebugItem>();
            var added = new List<string>();
            foreach(IDev2Definition dev2Definition in values)
            {


                var defn = GetVariableName(dev2Definition);
                if(added.Any(a => a == defn))
                    continue;

                added.Add(defn);
                DebugItem itemToAdd = new DebugItem();
                _add(new DebugEvalResult(DataListUtil.ReplaceRecordBlankWithStar(defn), "", dataObject.Environment), itemToAdd);
                results.Add(itemToAdd);
            }

            foreach(IDebugItem debugInput in results)
            {
                debugInput.FlushStringBuilder();
            }

            return results;
        }