public void AddItemsTest()
        {
            Context target = new Context();
            var type = target.Type.Add(new go.DB.JournalingBase.UsageSample.Entities.Type() { Name = "Type 1" });
            var thing = target.Thing.Add(new go.DB.JournalingBase.UsageSample.Entities.Thing() { Name = "Thing 1", Type = type });
            int expected = 2; // 2 changed records
            int actual;
            actual = target.SaveChanges();
            Assert.AreEqual(expected, actual);

            Assert.AreEqual(type.Id, type.OriginalId);
            Assert.AreEqual(thing.Id, thing.OriginalId);
        }
        public void UpdateItemsTest()
        {
            Context target = new Context();
            var type = target.Type.Add(new go.DB.JournalingBase.UsageSample.Entities.Type() { Name = "Type 1" });
            var thing = target.Thing.Add(new go.DB.JournalingBase.UsageSample.Entities.Thing() { Name = "Thing 1", Type = type });
            int expected = 2; // 2 changed records
            int actual;
            actual = target.SaveChanges();

            type.Name = "Type 1 new name";
            thing.Name = "Thing 1 new name";
            actual = target.SaveChanges();
            // we expect changed items to be updated (marked as deleted) and new versions of them added
            // so that is 2 items for each changed item
            Assert.AreEqual(expected * 2, actual);
        }
        public void DeleteItemsTest()
        {
            Context target = new Context();
            var type = target.Type.Add(new go.DB.JournalingBase.UsageSample.Entities.Type() { Name = "Type 1" });
            var thing = target.Thing.Add(new go.DB.JournalingBase.UsageSample.Entities.Thing() { Name = "Thing 1", Type = type });
            int expected = 2; // 2 changed records
            int actual;
            actual = target.SaveChanges();

            target.Type.Remove(type);
            target.Thing.Remove(thing);
            Assert.IsFalse(type.DateDeleted.HasValue);
            Assert.IsFalse(type.DateDeleted.HasValue);

            actual = target.SaveChanges();
            // we expect deleted items to be updated (marked as deleted)
            Assert.AreEqual(expected, actual);

            Assert.IsTrue(type.DateDeleted.HasValue);
            Assert.IsTrue(type.DateDeleted.HasValue);
            Assert.IsFalse(target.Thing.ToList().Where(e => e.IsActive()).Contains(thing));
            Assert.IsFalse(target.Type.ToList().Where(e => e.IsActive()).Contains(type));
            Assert.IsTrue(target.Thing.ToList().Where(e => !e.IsActive()).Contains(thing));
            Assert.IsTrue(target.Type.ToList().Where(e => !e.IsActive()).Contains(type));
        }