public void LoggableEntity_CreatesPropertiesForModifiedEntity() { String title = model.Title; entry.State = EntityState.Modified; entry.CurrentValues["Title"] = "Role"; entry.OriginalValues["Title"] = "Role"; IEnumerator<LoggableProperty> expected = new List<LoggableProperty> { new LoggableProperty(entry.Property("Title"), title) }.GetEnumerator(); IEnumerator<LoggableProperty> actual = new LoggableEntity(entry).Properties.GetEnumerator(); while (expected.MoveNext() | actual.MoveNext()) { Assert.Equal(expected.Current.IsModified, actual.Current.IsModified); Assert.Equal(expected.Current.ToString(), actual.Current.ToString()); } }
public void LoggableEntity_CreatesPropertiesForAttachedEntity() { context.Dispose(); String title = model.Title; context = new TestingContext(); context.Set<Role>().Attach(model); entry = context.Entry<BaseModel>(model); entry.OriginalValues["Title"] = "Role"; entry.CurrentValues["Title"] = "Role"; entry.State = EntityState.Modified; IEnumerator<LoggableProperty> expected = new List<LoggableProperty> { new LoggableProperty(entry.Property("Title"), title) }.GetEnumerator(); IEnumerator<LoggableProperty> actual = new LoggableEntity(entry).Properties.GetEnumerator(); while (expected.MoveNext() | actual.MoveNext()) { Assert.Equal(expected.Current.IsModified, actual.Current.IsModified); Assert.Equal(expected.Current.ToString(), actual.Current.ToString()); } }
private void AsssertProperties(DbPropertyValues originalValues) { IEnumerable<String> properties = originalValues.PropertyNames; IEnumerator<LoggableProperty> actual = new LoggableEntity(entry).Properties.GetEnumerator(); IEnumerator<LoggableProperty> expected = properties.Where(property => property != "Id") .Select(name => new LoggableProperty(entry.Property(name), originalValues[name])).GetEnumerator(); while (expected.MoveNext() | actual.MoveNext()) { Assert.Equal(expected.Current.IsModified, actual.Current.IsModified); Assert.Equal(expected.Current.ToString(), actual.Current.ToString()); } }