示例#1
0
        public void ReportChangesThrowsWhenAfterSnapshotNotPresent()
        {
            //Arrange/Act
            var snapshots = new SnapshotCollection(GetType(), t => t != typeof(Snapshots.TestDefinitions.TableDef));

            snapshots.DefineTable("Customer")
            .PrimaryKey("Id")
            .CompareKey("Surname")
            .IsUnpredictable("Id");

            var customers = new[]
            {
                new { Id = 1, Surname = "S1", FirstName = "F1", Age = 40 },
            };
            var builder = snapshots.NewSnapshot("Before");

            customers.ToSnapshotTable(builder, "Customer");

            var output = new Output();

            //Assert
            Action action = () => snapshots.ReportChanges("Before", "After", output);

            action.Should().Throw <SnapshotNotFoundException>().Where(x => x.SnapshotName == "After");
        }
示例#2
0
 public void ReportChanges(string before, string after, Output output, ChangeReportOptions changeReportOptions = ChangeReportOptions.Default)
 {
     lock (_lock)
     {
         ConfigureCollection();
         _collection.ReportChanges(before, after, output, changeReportOptions);
     }
 }
示例#3
0
        public void SubstitutionsCanBeDisabledInDiffReports()
        {
            //Arrange
            var snapshots = new SnapshotCollection();

            snapshots.DefineTable("Customer")
            .PrimaryKey("Id")
            .CompareKey("Surname")
            .IsUnpredictable("Id");
            snapshots.DefineTable("Address")
            .PrimaryKey("AddressId")
            .IsUnpredictable("AddressId")
            .IsReference("CustomerId", "Customer", "Id");

            var customers = new[]
            {
                new { Id = 1, Surname = "S1", FirstName = "F1", Age = 40 },
                new { Id = 2, Surname = "S2", FirstName = "F2", Age = 45 },
                new { Id = 3, Surname = "S3", FirstName = "F3", Age = 50 },
            };

            var addresses = new[]
            {
                new { AddressId = 102, CustomerId = 1, House = 15, Street = "Line 1", PostCode = "code1" },
                new { AddressId = 193, CustomerId = 2, House = 99, Street = "Line 2", PostCode = "code2" },
                new { AddressId = 6985, CustomerId = 3, House = 8000, Street = "Line 3", PostCode = "code3" }
            };

            {
                var builder = snapshots.NewSnapshot("Before");
                customers.ToSnapshotTable(builder, "Customer");
                addresses.ToSnapshotTable(builder, "Address");
            }

            customers[1] = new { Id = 2, Surname = "S2", FirstName = "F2Edited", Age = 32 };
            addresses[2] = new { AddressId = 6985, CustomerId = 2, House = 8001, Street = "Line 3", PostCode = "code3" };

            {
                var builder2 = snapshots.NewSnapshot("After");
                customers.ToSnapshotTable(builder2, "Customer");
                addresses.ToSnapshotTable(builder2, "Address");
            }

            //Act/Assert
            var output = new Output();

            snapshots.ReportChanges("Before", "After", output, ChangeReportOptions.NoSubs);
            output.Report.Verify();
        }