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 samplers = new SamplersFactory <DataRow>().Instantiate(FailureReportProfile.Default);
            var msg      = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);

            msg.BuildComparaison(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 + 3));
        }
        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 samplers = new SamplersFactory <DataRow>().Instantiate(FailureReportProfile.Default);
            var msg      = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);

            msg.BuildComparaison(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("Result-set with 1 row"));
        }
        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 samplers = new SamplersFactory <DataRow>().Instantiate(FailureReportProfile.Default);
            var msg      = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);

            msg.BuildComparaison(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."));
        }
Esempio n. 4
0
        public void RenderExpected_LessThanMaxRowsCount_DoesntDisplaySkippedRow(int rowCount)
        {
            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 samplers = new SamplersFactory <DataRow>().Instantiate(FailureReportProfile.Default);
            var msg      = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);

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

            Assert.That(value, Does.Not.Contain("rows have been skipped for display purpose."));
        }
        public void RenderExpected_MoreThanSampleRowsCountButLessThanMaxRowsCountWithSpecificProfileNone_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.None
                                                          );

            var samplers = new SamplersFactory <DataRow>().Instantiate(profile);
            var msg      = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);

            msg.BuildComparaison(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(0));
            Assert.That(lines, Has.All.EqualTo("Display skipped."));
        }
        public void RenderCompared_WithSpecialRows_DisplayTextForThisKindOfRows(
            int missingRowCount
            , int unexpectedRowCount
            , int duplicatedRowCount
            , int keyMatchingRowCount
            , int nonMatchingValueRowCount
            , string expectedText)
        {
            var compared = ResultResultSet.Build(
                GetDataRows(missingRowCount)
                , GetDataRows(unexpectedRowCount)
                , GetDataRows(duplicatedRowCount)
                , GetDataRows(keyMatchingRowCount)
                , GetDataRows(nonMatchingValueRowCount)
                );

            var samplers = new SamplersFactory <DataRow>().Instantiate(FailureReportProfile.Default);
            var msg      = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);

            msg.BuildComparaison(null, null, compared);
            var value = msg.RenderAnalysis();

            Assert.That(value, Is.StringContaining(expectedText));
        }