コード例 #1
0
        public void FormatResult_Returns_InternalSearchResult()
        {
            // Arrange.
            const string ProcessDisplayName = "Test Process";
            const int TotalRowCount = 123;
            const int PageNumber = 3;

            var items = new InfoList<IInfoClass>
                            {
                                new InfoItem { Field1 = "Value 1.1", Field2 = "Value 1.2", Field3 = "Value 1.3" },
                                new InfoItem { Field1 = "Value 2.1", Field2 = "Value 2.2", Field3 = "Value 2.3" }
                            };
            items.TotalRowCount = TotalRowCount;
            items.PageNumber = PageNumber;

            var filters = new List<Filter> { new Filter(), new Filter() };
            var layouts = new List<LayoutMetadata> { new LayoutMetadata(), new LayoutMetadata() };
            var relatedProcesses = new List<ProcessMetadata> { new ProcessMetadata(), new ProcessMetadata() };
            var appliedFilter = new Filter();
            var appliedLayout = new LayoutMetadata();

            var searchResult = new SearchCommandResult
                                   {
                                       ProcessDisplayName = ProcessDisplayName,
                                       AppliedFilter = appliedFilter,
                                       FilterParametersRequired = false,
                                       AppliedLayout = appliedLayout,
                                       Items = items,
                                       ResultColumns = { CreateColumnMetadata("Field1"), CreateColumnMetadata("Field3") },
                                       Filters = filters,
                                       Layouts = layouts,
                                       RelatedProcesses = relatedProcesses
                                   };

            var formatter = new InternalSearchResultFormatter(_colorTranslator);

            // Act.
            var result = formatter.FormatResult(searchResult);

            // Assert.
            Assert.IsNotNull(result);
            Assert.AreEqual(ProcessDisplayName, result.ProcessDisplayName);
            Assert.AreSame(appliedFilter, result.AppliedFilter);
            Assert.IsFalse(result.FilterParametersRequired);
            Assert.AreSame(appliedLayout, result.AppliedLayout);
            Assert.AreEqual(PageNumber, result.CurrentPage);
            Assert.AreEqual(TotalRowCount, result.TotalRowCount);
            Assert.IsTrue(result.Filters.SequenceEqual(filters));
            Assert.IsTrue(result.Layouts.SequenceEqual(layouts));
            Assert.IsTrue(result.RelatedProcesses.SequenceEqual(relatedProcesses));

            Assert.IsNotNull(result.Items);
            Assert.AreEqual(2, result.Items.Count);
            Assert.IsTrue(result.Items[0].Values.SequenceEqual(new[] { "Value 1.1", "Value 1.3" }));
            Assert.IsTrue(result.Items[1].Values.SequenceEqual(new[] { "Value 2.1", "Value 2.3" }));
        }
コード例 #2
0
        public void FormattedResult_Includes_BlockedColumns()
        {
            // Arrange.
            var item = new InfoItem { Field1 = "Value 1", Field2 = "Value 2", Field3 = "Value 3", BlockedFields = { "Field2" } };
            var searchResult = new SearchCommandResult
                                   {
                                       Items = new InfoList<IInfoClass> { item },
                                       ResultColumns =
                                           {
                                               CreateColumnMetadata("Field1"),
                                               CreateColumnMetadata("Field2"),
                                               CreateColumnMetadata("Field3")
                                           }
                                   };

            var formatter = new InternalSearchResultFormatter(_colorTranslator);

            // Act.
            var result = formatter.FormatResult(searchResult);

            // Assert.
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Items);
            Assert.AreEqual(1, result.Items.Count);
            Assert.IsTrue(result.Items[0].BlockedColumns.SequenceEqual(new[] { 1 }));
        }
コード例 #3
0
        public void WhenItemsIsNull_FormatResult_ReturnsValidResult()
        {
            // Arrange.
            const string ProcessDisplayName = "Test Process";

            var filters = new List<Filter> { new Filter(), new Filter() };
            var layouts = new List<LayoutMetadata> { new LayoutMetadata(), new LayoutMetadata() };
            var relatedProcesses = new List<ProcessMetadata> { new ProcessMetadata(), new ProcessMetadata() };
            var appliedFilter = new Filter();
            var appliedLayout = new LayoutMetadata();

            var searchResult = new SearchCommandResult
                                   {
                                       ProcessDisplayName = ProcessDisplayName,
                                       AppliedFilter = appliedFilter,
                                       FilterParametersRequired = true,
                                       AppliedLayout = appliedLayout,
                                       Items = null,
                                       ResultColumns = { CreateColumnMetadata("Field1"), CreateColumnMetadata("Field3") },
                                       Filters = filters,
                                       Layouts = layouts,
                                       RelatedProcesses = relatedProcesses
                                   };

            var formatter = new InternalSearchResultFormatter(_colorTranslator);

            // Act.
            var result = formatter.FormatResult(searchResult);

            // Assert.
            Assert.IsNotNull(result);
            Assert.AreEqual(ProcessDisplayName, result.ProcessDisplayName);
            Assert.AreSame(appliedFilter, result.AppliedFilter);
            Assert.IsTrue(result.FilterParametersRequired);
            Assert.AreSame(appliedLayout, result.AppliedLayout);
            Assert.AreEqual(-1, result.CurrentPage);
            Assert.AreEqual(0, result.TotalRowCount);
            Assert.IsTrue(result.Filters.SequenceEqual(filters));
            Assert.IsTrue(result.Layouts.SequenceEqual(layouts));
            Assert.IsTrue(result.RelatedProcesses.SequenceEqual(relatedProcesses));
            Assert.IsNull(result.Items);
        }