Exemplo n.º 1
0
        public LoggablePropertyTests()
        {
            using (TestingContext context = new TestingContext())
            {
                TestModel model = ObjectFactory.CreateTestModel();

                context.Set<TestModel>().Add(model);
                context.Entry(model).State = EntityState.Modified;
                textProperty = context.Entry(model).Property(prop => prop.Text);
                dateProperty = context.Entry(model).Property(prop => prop.CreationDate);
            }
        }
Exemplo n.º 2
0
        public AuditLoggerTests()
        {
            context = new TestingContext();
            dataContext = new TestingContext();
            TestModel model = ObjectFactory.CreateTestModel();
            logger = Substitute.ForPartsOf<AuditLogger>(context);

            entry = dataContext.Entry<BaseModel>(dataContext.Set<TestModel>().Add(model));
            dataContext.Set<TestModel>().RemoveRange(dataContext.Set<TestModel>());
            dataContext.SaveChanges();
        }
Exemplo n.º 3
0
        public LoggableEntityTests()
        {
            using (context = new TestingContext())
            {
                context.DropData();
                SetUpData();
            }

            context = new TestingContext();
            model = context.Set<Role>().Single();
            entry = context.Entry<BaseModel>(model);
        }
Exemplo n.º 4
0
        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());
            }
        }