public void When_Rows_do_not_match_and_property_is_not_excluded_it_should_fail(ChangeType changeType, bool acceptChanges)
        {
            // Arrange
            var dataSet1 = CreateDummyDataSet <TypedDataSetSubclass>();

            var dataSet2 = new TypedDataSetSubclass(dataSet1);

            var dataTable1 = dataSet1.TypedDataTable1;
            var dataTable2 = dataSet2.TypedDataTable1;

            ApplyChange(dataTable2.Rows, dataTable2, changeType);

            if (acceptChanges)
            {
                dataTable2.AcceptChanges();
            }

            // Act
            Action action = () => dataTable1.Should().BeEquivalentTo(dataTable2);

            // Assert
            action.Should().Throw <XunitException>();
        }
        public void When_PrimaryKey_does_not_match_and_property_is_excluded_it_should_succeed()
        {
            // Arrange
            var dataSet1 = CreateDummyDataSet <TypedDataSetSubclass>();

            for (int i = 2; i < dataSet1.TypedDataTable2.Columns.Count; i++)
            {
                dataSet1.TypedDataTable2.Columns[i].AllowDBNull = false;
            }

            var dataSet2 = new TypedDataSetSubclass(dataSet1);

            var dataTable1 = dataSet1.TypedDataTable2;
            var dataTable2 = dataSet2.TypedDataTable2;

            dataTable2.PrimaryKey        = dataTable2.Columns.Cast <DataColumn>().Skip(2).ToArray();
            dataTable2.Columns[0].Unique = true;

            // Act & Assert
            dataTable1.Should().BeEquivalentTo(dataTable2, options => options
                                               .Excluding(dataTable => dataTable.PrimaryKey)
                                               .Excluding(dataTable => dataTable.Constraints));
        }
            public void When_DataRow_is_modified_and_original_data_differs_and_original_data_is_excluded_it_should_succeed()
            {
                // Arrange
                var dataSet1 = CreateDummyDataSet <TypedDataSetSubclass>();
                var dataSet2 = new TypedDataSetSubclass(dataSet1);

                var dataTable1 = dataSet1.TypedDataTable2;
                var dataTable2 = dataSet2.TypedDataTable2;

                var dataRow1 = dataTable1[0];
                var dataRow2 = dataTable2[0];

                dataRow1.Decimal++;
                dataTable1.AcceptChanges();
                dataRow1.Decimal--;

                dataRow2.Decimal--;
                dataTable2.AcceptChanges();
                dataRow2.Decimal++;

                // Act & Assert
                dataRow1.Should().BeEquivalentTo(dataRow2, config => config
                                                 .ExcludingOriginalData());
            }
예제 #4
0
        public void When_data_table_primary_key_does_not_match_and_the_corresponding_property_is_not_excluded_equivalence_test_should_fail()
        {
            // Arrange
            var typedDataSet1 = CreateDummyDataSet<TypedDataSetSubclass>();

            var typedDataSet2 = new TypedDataSetSubclass(typedDataSet1);

            var dataTable1 = typedDataSet1.ToUntypedDataSet().Tables["TypedDataTable2"];
            var dataTable2 = typedDataSet2.ToUntypedDataSet().Tables["TypedDataTable2"];

            dataTable1.Columns.Cast<DataColumn>().Skip(2).ToList()
                .ForEach(col => col.AllowDBNull = false);

            dataTable2.PrimaryKey = dataTable2.Columns.Cast<DataColumn>().Skip(2).ToArray();
            dataTable2.Columns[0].Unique = true;

            // Act
            Action action = () =>
                dataTable1.Should().BeEquivalentTo(dataTable2, options => options
                    .Excluding(dataTable => dataTable.Constraints));

            // Assert
            action.Should().Throw<XunitException>().WithMessage("Expected property dataTable1.PrimaryKey to be a collection with * item(s), but *contains * item(s) less than*");
        }