public void changeTrackingService_using_beginAtomicOperation_getEntities_should_return_all_changed_entities()
		{
			var target = new ChangeTrackingService();

			var person = new Person( target );
			var list = new PersonCollection( target );

			using( var op = target.BeginAtomicOperation() )
			{
				person.Name = "Mauro";
				list.Add( person );
				person.Name = "Mauro Servienti";

				op.Complete();
			}

			var actual = target.GetEntities( EntityTrackingStates.HasBackwardChanges, false );

			/*
			 * Non funziona perchè non funziona GetEntityState()
			 */

			actual.Contains( person ).Should().Be.True();
		}
		public void changeTrackingService_using_beginAtomicOperation_getEntities_should_return_all_transient_entities()
		{
			var target = new ChangeTrackingService();

			var list = new PersonCollection( target );
			var person = new Person( target, false );

			using( var op = target.BeginAtomicOperation() )
			{
				target.RegisterTransient( person );
				person.Name = "Mauro";
				list.Add( person );
				person.Name = "Mauro Servienti";

				op.Complete();
			}

			var actual = target.GetEntities( EntityTrackingStates.IsTransient, false );

			actual.Contains( person ).Should().Be.True();
		}
        public void unchangedTransientEntity_service_RejectChanges_entity_is_not_transient()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            Person p = new Person( svc );

            svc.RejectChanges();

            var list = svc.GetEntities( EntityTrackingStates.IsTransient, false );
            var persons = list.OfType<Person>();

            Assert.IsFalse( persons.Contains( p ) );
        }
        public void service_initial_state_has_no_transient_entities()
        {
            ChangeTrackingService svc = new ChangeTrackingService();
            IEnumerable entities = svc.GetEntities( EntityTrackingStates.IsTransient, false );

            Assert.AreEqual<Int32>( 0, entities.OfType<Object>().Count() );
        }
        public void unchangedTransientEntity_service_getTransientEntities_contains_entity()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            Person p = new Person( svc );

            var list = svc.GetEntities( EntityTrackingStates.IsTransient, false );
            var persons = list.OfType<Person>();

            Assert.IsTrue( persons.Contains( p ) );
        }
        public void service_getEntities_state_Transient_exactMatch_false_entity_in_Changed_and_Transient_state()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            Person p = new Person( svc );
            p.Name = "Mauro";
            p.Name = "Mauro";
            p.Name = "Foo";

            IEnumerable<Object> entities = svc.GetEntities( EntityTrackingStates.IsTransient, false );

            Assert.AreEqual<Int32>( 1, entities.Count() );
        }
        public void service_getEntities_state_Changed_exactMatch_true_entity_in_Changed_state()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            Person p = new Person( svc, false );
            p.Name = "Mauro";
            p.Name = "Mauro";
            p.Name = "Foo";

            IEnumerable<Object> entities = svc.GetEntities( EntityTrackingStates.HasBackwardChanges, true );

            Assert.AreEqual<Int32>( 1, entities.Count() );
        }
        public void service_getEntities_gets_all_tracked_entities()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            Person p1 = new Person( svc, true );
            p1.Name = "Mauro";
            p1.Name = "Mauro";
            p1.Name = "Foo";

            Person p2 = new Person( svc, true );

            IEnumerable<Object> entities = svc.GetEntities();

            Assert.AreEqual<Int32>( 2, entities.Count() );
        }
        public void service_getEntities_state_None_exactMatch_false_gets_all_tracked_entities()
        {
            ChangeTrackingService svc = new ChangeTrackingService();

            Person p = new Person( svc, true );
            p.Name = "Mauro";
            p.Name = "Mauro";
            p.Name = "Foo";

            IEnumerable<Object> entities = svc.GetEntities( EntityTrackingStates.None, false );

            Assert.AreEqual<Int32>( 1, entities.Count() );
        }