Beispiel #1
0
        protected bool doMatch(ResultSet actual)
        {
            actualResultSet = actual;

            //This is needed if we don't use //ism
            if (expectedResultSet == null)
            {
                expectedResultSet = GetResultSet(expect);
            }

            result = Engine.Compare(actualResultSet, expectedResultSet);

            //  Math.Min for result.Difference limits the value to 1 if we've two non matching resultsets
            if ((int)persistanceChoice + Math.Min(1, (int)result.Difference) > 1)
            {
                if ((persistanceItems & PersistanceItems.expected) == PersistanceItems.expected)
                {
                    doPersist(expectedResultSet, GetPersistancePath("Expect"));
                }
                if ((persistanceItems & PersistanceItems.actual) == PersistanceItems.actual)
                {
                    doPersist(actualResultSet, GetPersistancePath("Actual"));
                }
            }

            return(result.Difference == ResultSetDifferenceType.None);
        }
Beispiel #2
0
        protected void DisplayDifferences(NUnitCtr.MessageWriter writer, ResultSetCompareResult compareResult)
        {
            if (compareResult.Unexpected.Count > 0)
            {
                writer.WriteLine("  Unexpected rows:");
                writer.WriteLine();
                FormatResultSet(writer, compareResult.Unexpected, false);
                writer.WriteLine();
            }

            if (compareResult.Missing.Count > 0)
            {
                writer.WriteLine("  Missing rows:");
                writer.WriteLine();
                FormatResultSet(writer, compareResult.Missing, false);
                writer.WriteLine();
            }

            if (compareResult.Duplicated.Count > 0)
            {
                writer.WriteLine("  Duplicated rows:");
                writer.WriteLine();
                FormatResultSet(writer, compareResult.Duplicated, true);
                writer.WriteLine();
            }

            if (compareResult.NonMatchingValue.Count > 0)
            {
                writer.WriteLine("  Non matching value rows:");
                writer.WriteLine();
                FormatResultSet(writer, compareResult.NonMatchingValue, true);
                writer.WriteLine();
            }
        }
        public void BuildComparaison(IEnumerable <DataRow> expectedRows, IEnumerable <DataRow> actualRows, ResultSetCompareResult compareResult)
        {
            compareResult = compareResult ?? ResultSetCompareResult.Build(new List <DataRow>(), new List <DataRow>(), new List <DataRow>(), new List <DataRow>(), new List <DataRow>());

            expected = BuildTable(style, expectedRows, Profile.ExpectedSet);
            actual   = BuildTable(style, actualRows, Profile.ActualSet);
            compared = BuildNonEmptyTable(style, compareResult.Unexpected, "Unexpected", Profile.AnalysisSet);
            compared.Append(BuildNonEmptyTable(style, compareResult.Missing ?? new List <DataRow>(), "Missing", Profile.AnalysisSet));
            compared.Append(BuildNonEmptyTable(style, compareResult.Duplicated ?? new List <DataRow>(), "Duplicated", Profile.AnalysisSet));
            compared.Append(BuildCompareTable(style, compareResult.NonMatchingValue.Rows ?? new List <DataRow>(), "Non matching value", Profile.AnalysisSet));
        }
Beispiel #4
0
        public void RenderCompared_WithSpecialRows_DisplayTextForThisKindOfRows(
            int missingRowCount
            , int unexpectedRowCount
            , int duplicatedRowCount
            , int keyMatchingRowCount
            , int nonMatchingValueRowCount
            , string expectedText)
        {
            var compared = ResultSetCompareResult.Build(
                GetDataRows(missingRowCount)
                , GetDataRows(unexpectedRowCount)
                , GetDataRows(duplicatedRowCount)
                , GetDataRows(keyMatchingRowCount)
                , GetDataRows(nonMatchingValueRowCount)
                );


            var msg = new DataRowsMessage(FailureReportProfile.Default);

            msg.Build(null, null, compared);
            var value = msg.RenderCompared();

            Assert.That(value, Is.StringContaining(expectedText));
        }
Beispiel #5
0
        protected bool doMatch(ResultSet actual)
        {
            actualResultSet = actual;

            //This is needed if we don't use //ism
            if (expectedResultSet ==  null)
                expectedResultSet = GetResultSet(expect);

            result = Engine.Compare(actualResultSet, expectedResultSet);

            //  Math.Min for result.Difference limits the value to 1 if we've two non matching resultsets
            if ((int)persistanceChoice + Math.Min(1,(int)result.Difference) > 1)
            {
                if ((persistanceItems & PersistanceItems.expected) == PersistanceItems.expected)
                    doPersist(expectedResultSet, GetPersistancePath("Expect"));
                if ((persistanceItems & PersistanceItems.actual) == PersistanceItems.actual)
                    doPersist(actualResultSet, GetPersistancePath("Actual"));
            }

            return result.Difference == ResultSetDifferenceType.None;
        }
 protected virtual void FormatResultSet(NUnitCtr.MessageWriter writer, ResultSetCompareResult.Sample sample, bool compare)
 {
     var textCreator = new ResultSetTextWriter();
     var output = textCreator.BuildContent(sample.Rows, sample.Count, compare);
     foreach (var line in output)
         writer.WriteLine(line);
 }
Beispiel #7
0
        protected void DisplayDifferences(NUnitCtr.MessageWriter writer, ResultSetCompareResult compareResult)
        {
            if (compareResult.Unexpected.Count > 0)
            {
                writer.WriteLine("  Unexpected rows:");
                writer.WriteLine();
                FormatResultSet(writer, compareResult.Unexpected, false);
                writer.WriteLine();
            }

            if (compareResult.Missing.Count > 0)
            {
                writer.WriteLine("  Missing rows:");
                writer.WriteLine();
                FormatResultSet(writer, compareResult.Missing, false);
                writer.WriteLine();
            }

            if (compareResult.Duplicated.Count > 0)
            {
                writer.WriteLine("  Duplicated rows:");
                writer.WriteLine();
                FormatResultSet(writer, compareResult.Duplicated, true);
                writer.WriteLine();
            }

            if (compareResult.NonMatchingValue.Count > 0)
            {
                writer.WriteLine("  Non matching value rows:");
                writer.WriteLine();
                FormatResultSet(writer, compareResult.NonMatchingValue, true);
                writer.WriteLine();
            }
        }