public void Can_track_complex_type_property_change()
        {
            //add enity
            string oldDescription = RandomText;
            string newDescription = RandomText;

            //only set one of the properties on the complex type
            var complexType = new ComplexType {
                Property1 = oldDescription
            };
            var entity = new ModelWithComplexType {
                ComplexType = complexType
            };

            Db.Entry(entity).State = EntityState.Added;
            Db.SaveChanges();

            //modify entity
            entity.ComplexType.Property1 = newDescription;
            Db.SaveChanges();

            AuditLogDetail[] expectedLog = new List <AuditLogDetail>
            {
                new AuditLogDetail
                {
                    NewValue      = newDescription,
                    OriginalValue = oldDescription,
                    PropertyName  = "ComplexType_Property1"
                }
            }.ToArray();


            //assert
            entity.AssertAuditForModification(Db, entity.Id, null, expectedLog);
        }
        public void Can_track_complex_type_property_change()
        {
            var options = new DbContextOptionsBuilder <TestTrackerContext>()
                          .UseSqlServer(TestConnectionString)
                          .Options;

            //add enity
            string oldDescription = rdg.Get <string>();
            string newDescription = rdg.Get <string>();

            //only set one of the properties on the complex type
            var complexType = new ComplexType {
                Property1 = oldDescription
            };
            var entity = new ModelWithComplexType {
                ComplexType = complexType
            };

            using (TestTrackerContext ttc = new TestTrackerContext(options))
            {
                ttc.Entry(entity).State = EntityState.Added;
                ttc.SaveChanges();

                //modify entity
                entity.ComplexType.Property1 = newDescription;
                ttc.SaveChanges();

                AuditLogDetail[] expectedLog = new List <AuditLogDetail>
                {
                    new AuditLogDetail
                    {
                        NewValue      = newDescription,
                        OriginalValue = oldDescription,
                        PropertyName  = "ComplexType_Property1"
                    }
                }.ToArray();

                //assert
                entity.AssertAuditForModification(ttc, entity.Id, null, expectedLog);
            }
        }