Example #1
0
        public void service_on_clear_generate_valid_advisory()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            PersonCollection p = new PersonCollection(svc);

            p.Add(new Person(null, false));
            p.Add(new Person(null, false));
            p.Add(new Person(null, false));
            p.Add(new Person(null, false));
            p.Add(new Person(null, false));

            svc.AcceptChanges();

            p.Clear();

            IEnumerable <IAdvisedAction> advisory = svc.GetAdvisory();

            Assert.IsNotNull(advisory);
            Assert.AreEqual <int>(5, advisory.Count());
            foreach (var aa in advisory)
            {
                Assert.AreEqual <ProposedActions>(ProposedActions.Delete, aa.Action);
            }
        }
Example #2
0
        public void service_on_single_add_generate_valid_advisory_even_with_transient_persistable_entity()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            PersonCollection p = new PersonCollection(svc);

            p.Add(new Person(null, ChangeTrackingRegistration.AsTransient, TransientRegistration.AsPersistable));

            IEnumerable <IAdvisedAction> advisory = svc.GetAdvisory();

            Assert.IsNotNull(advisory);
            Assert.AreEqual <int>(1, advisory.Count());
            Assert.AreEqual <ProposedActions>(ProposedActions.Create, advisory.First().Action);
        }
Example #3
0
        public void service_on_single_add_generate_valid_advisory()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            PersonCollection p = new PersonCollection(svc);

            p.Add(new Person(null, false));

            IEnumerable <IAdvisedAction> advisory = svc.GetAdvisory();

            Assert.IsNotNull(advisory);
            Assert.AreEqual <int>(1, advisory.Count());
            Assert.AreEqual <ProposedActions>(ProposedActions.Update, advisory.First().Action);
        }
Example #4
0
        public void service_getAdvisory_generate_valid_advisory_with_more_changes_applied_to_the_same_entity()
        {
            ProposedActions       expected = ProposedActions.Delete;
            ChangeTrackingService svc      = new ChangeTrackingService();

            PersonCollection list = new PersonCollection(svc);

            list.Add(new Person(null, false));    //First IChange
            list.RemoveAt(0);                     //Second IChange

            IAdvisory       advisory = svc.GetAdvisory();
            IAdvisedAction  action   = advisory.First();
            ProposedActions actual   = action.Action;

            Assert.AreEqual <ProposedActions>(expected, actual);
        }