예제 #1
0
        public void RenderExpected_OneRow_ReturnCorrectNumberOfRowsOnTopWithoutPlurial()
        {
            var dataSet   = new DataSet();
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < 1; i++)
            {
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);
            }

            var msg = new DataRowsMessage(FailureReportProfile.Default);

            msg.Build(dataTable.Rows.Cast <DataRow>(), null, null);
            var value = msg.RenderExpected();
            var lines = value.Replace("\n", string.Empty).Split('\r');


            Assert.That(lines[0], Is.EqualTo("ResultSet with 1 row"));
        }
예제 #2
0
        protected virtual DataRowsMessage BuildFailure()
        {
            var msg = new DataRowsMessage(Configuration.FailureReportProfile);

            msg.BuildCount(actualResultSet.Rows.Cast <DataRow>());
            return(msg);
        }
예제 #3
0
        public void RenderExpected_MoreThanMaxRowsCount_ReturnSampleRowsCountAndHeaderAndSeparation()
        {
            var dataSet   = new DataSet();
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < 20; i++)
            {
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);
            }

            var msg = new DataRowsMessage(FailureReportProfile.Default);

            msg.Build(dataTable.Rows.Cast <DataRow>(), null, null);
            var value = msg.RenderExpected();
            var lines = value.Replace("\n", string.Empty).Split('\r');


            Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(10 + 2));
        }
예제 #4
0
        protected override DataRowsMessage BuildFailure()
        {
            var msg = new DataRowsMessage(Configuration.FailureReportProfile);

            msg.BuildFilter(actualResultSet.Rows.Cast <DataRow>(), filterResultSet.Rows.Cast <DataRow>());
            return(msg);
        }
예제 #5
0
        protected DataRowsMessage BuildFailure()
        {
            var msg = new DataRowsMessage(Configuration.FailureReportProfile);

            msg.BuildComparaison(expectedResultSet.Rows.Cast <DataRow>(), actualResultSet.Rows.Cast <DataRow>(), result);
            return(msg);
        }
예제 #6
0
        public void RenderExpected_MoreThanSampleRowsCountButLessThanMaxRowsCountWithSpecificProfileFull_ReturnEachRowAndHeaderAndSeparation()
        {
            var rowCount  = 120;
            var threshold = rowCount - 20;
            var max       = threshold / 2;

            var dataSet   = new DataSet();
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < rowCount; i++)
            {
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);
            }

            var profile = Mock.Of <IFailureReportProfile>(p =>
                                                          p.MaxSampleItem == max &&
                                                          p.ThresholdSampleItem == threshold &&
                                                          p.ExpectedSet == FailureReportSetType.Full
                                                          );

            var msg = new DataRowsMessage(profile);

            msg.Build(dataTable.Rows.Cast <DataRow>(), null, null);
            var value = msg.RenderExpected();
            var lines = value.Replace("\n", string.Empty).Split('\r');


            Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(rowCount + 2));
        }
예제 #7
0
        public void RenderExpected_MoreThanMaxRowsCount_ReturnCorrectCountOfSkippedRow()
        {
            var dataSet   = new DataSet();
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < 22; i++)
            {
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);
            }

            var msg = new DataRowsMessage(FailureReportProfile.Default);

            msg.Build(dataTable.Rows.Cast <DataRow>(), null, null);
            var value = msg.RenderExpected();
            var lines = value.Replace("\n", string.Empty).Split('\r');
            //Not exactly the last line but the previous due to paragraph rendering.
            var lastLine = lines.Reverse().ElementAt(1);

            Assert.That(lastLine, Is.EqualTo("12 (of 22) rows have been skipped for display purpose."));
        }
예제 #8
0
        /// <summary>
        /// Handle an IDbCommand and compare it to a predefined resultset
        /// </summary>
        /// <param name="actual">An IDbCommand or a result-set or the path to a file containing a result-set</param>
        /// <returns>true, if the result-set has unique rows</returns>
        public override bool Matches(object actual)
        {
            this.actual     = actual;
            actualResultSet = new ResultSetBuilder().Build(actual);
            var result = Engine.Execute(actualResultSet);

            if (!result.AreUnique)
            {
                failure = new DataRowsMessage(ComparisonStyle.ByIndex, Configuration.FailureReportProfile);
                failure.BuildDuplication(actualResultSet.Rows.Cast <DataRow>(), result);
            }

            return(result.AreUnique);
        }
예제 #9
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));
        }
예제 #10
0
        public void RenderExpected_LessThanMaxRowsCount_DoesntDisplaySkippedRow(int rowCount)
        {
            var dataSet   = new DataSet();
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < rowCount; i++)
            {
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);
            }

            var msg = new DataRowsMessage(FailureReportProfile.Default);

            msg.Build(dataTable.Rows.Cast <DataRow>(), null, null);
            var value = msg.RenderExpected();

            Assert.That(value, Is.Not.StringContaining("rows have been skipped for display purpose."));
        }
예제 #11
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));
        }
예제 #12
0
        public void RenderExpected_MoreThanSampleRowsCountButLessThanMaxRowsCountWithSpecificProfile_ReturnEachRowAndHeaderAndSeparation()
        {
            var rowCount = 120;
            var threshold = rowCount - 20;
            var max = threshold / 2;

            var dataSet = new DataSet();
            var dataTable = new DataTable() { TableName = "MyTable" };
            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < rowCount; i++)
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);

            var profile = Mock.Of<IFailureReportProfile>(p =>
                p.MaxSampleItem == max
                && p.ThresholdSampleItem == threshold
                && p.ExpectedSet == FailureReportSetType.Sample
            );

            var msg = new DataRowsMessage(profile);
            msg.Build(dataTable.Rows.Cast<DataRow>(), null, null);
            var value = msg.RenderExpected();
            var lines = value.Replace("\n", string.Empty).Split('\r');

            Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(max + 2));
        }
예제 #13
0
        public void RenderExpected_OneRow_ReturnCorrectNumberOfRowsOnTopWithoutPlurial()
        {
            var dataSet = new DataSet();
            var dataTable = new DataTable() { TableName = "MyTable" };
            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < 1; i++)
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);

            var msg = new DataRowsMessage(FailureReportProfile.Default);
            msg.Build(dataTable.Rows.Cast<DataRow>(), null, null);
            var value = msg.RenderExpected();
            var lines = value.Replace("\n", string.Empty).Split('\r');

            Assert.That(lines[0], Is.EqualTo("ResultSet with 1 row"));
        }
예제 #14
0
 protected DataRowsMessage BuildFailure()
 {
     var msg = new DataRowsMessage(Configuration.FailureReportProfile);
     msg.Build(expectedResultSet.Rows.Cast<DataRow>(), actualResultSet.Rows.Cast<DataRow>(), result);
     return msg;
 }
예제 #15
0
        public void RenderExpected_LessThanMaxRowsCount_DoesntDisplaySkippedRow(int rowCount)
        {
            var dataSet = new DataSet();
            var dataTable = new DataTable() { TableName = "MyTable" };
            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < rowCount; i++)
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);

            var msg = new DataRowsMessage(FailureReportProfile.Default);
            msg.Build(dataTable.Rows.Cast<DataRow>(), null, null);
            var value = msg.RenderExpected();

            Assert.That(value, Is.Not.StringContaining("rows have been skipped for display purpose."));
        }
예제 #16
0
        public void RenderExpected_MoreThanMaxRowsCount_ReturnCorrectCountOfSkippedRow()
        {
            var dataSet = new DataSet();
            var dataTable = new DataTable() { TableName = "MyTable" };
            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < 22; i++)
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);

            var msg = new DataRowsMessage(FailureReportProfile.Default);
            msg.Build(dataTable.Rows.Cast<DataRow>(), null, null);
            var value = msg.RenderExpected();
            var lines = value.Replace("\n", string.Empty).Split('\r');
            //Not exactly the last line but the previous due to paragraph rendering.
            var lastLine = lines.Reverse().ElementAt(1);

            Assert.That(lastLine, Is.EqualTo("12 (of 22) rows have been skipped for display purpose."));
        }
예제 #17
0
        public void RenderExpected_MoreThanSampleRowsCountButLessThanMaxRowsCount_ReturnEachRowAndHeaderAndSeparation()
        {
            var rowCount = 12;

            var dataSet = new DataSet();
            var dataTable = new DataTable() { TableName = "MyTable" };
            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            for (int i = 0; i < rowCount; i++)
                dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);

            var msg = new DataRowsMessage(FailureReportProfile.Default);
            msg.Build(dataTable.Rows.Cast<DataRow>(), null, null);
            var value = msg.RenderExpected();
            var lines = value.Replace("\n", string.Empty).Split('\r');

            Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(rowCount + 2));
        }