예제 #1
0
		protected virtual void TstDeletion()
		{
			A().Provider().StoreNew(new Pilot("Pilot1", 42));
			Pilot o = new Pilot("Pilot2", 43);
			A().Provider().StoreNew(o);
			A().Provider().Commit();
			A().Provider().StoreNew(new Pilot("Pilot3", 44));
			A().Provider().Delete(FindPilot("Pilot1"));
			Car car = new Car("Car1");
			car.SetPilot(FindPilot("Pilot2"));
			A().Provider().StoreNew(car);
			A().Provider().Commit();
			StartReplication();
			IDrsUUID uuidCar1 = Uuid(FindCar("Car1"));
			Assert.IsNotNull(uuidCar1);
			A().Provider().ReplicateDeletion(uuidCar1);
			CommitReplication();
			Assert.IsNull(FindCar("Car1"));
			StartReplication();
			IDrsUUID uuidPilot2 = Uuid(FindPilot("Pilot2"));
			Assert.IsNotNull(uuidPilot2);
			A().Provider().ReplicateDeletion(uuidPilot2);
			CommitReplication();
			Assert.IsNull(FindPilot("Pilot2"));
		}
예제 #2
0
		private void TstObjectsChangedSinceLastReplication()
		{
			Pilot object1 = new Pilot("John Cleese", 42);
			Pilot object2 = new Pilot("Terry Gilliam", 53);
			Car object3 = new Car("Volvo");
			A().Provider().StoreNew(object1);
			A().Provider().StoreNew(object2);
			A().Provider().StoreNew(object3);
			A().Provider().Commit();
			StartReplication();
			IObjectSet changed = A().Provider().ObjectsChangedSinceLastReplication();
			Assert.AreEqual(3, changed.Count);
			IObjectSet os = A().Provider().ObjectsChangedSinceLastReplication(typeof(Pilot));
			Assert.AreEqual(2, os.Count);
			IEnumerator pilots = os.GetEnumerator();
			//		Assert.isTrue(pilots.contains(findPilot("John Cleese")));
			//	Assert.isTrue(pilots.contains(findPilot("Terry Gilliam")));
			IEnumerator cars = A().Provider().ObjectsChangedSinceLastReplication(typeof(Car))
				.GetEnumerator();
			Assert.AreEqual("Volvo", ((Car)Next(cars)).GetModel());
			Assert.IsFalse(cars.MoveNext());
			CommitReplication();
			StartReplication();
			Assert.IsFalse(A().Provider().ObjectsChangedSinceLastReplication().GetEnumerator(
				).MoveNext());
			CommitReplication();
			Pilot pilot = (Pilot)Next(A().Provider().GetStoredObjects(typeof(Pilot)).GetEnumerator
				());
			pilot.SetName("Terry Jones");
			Car car = (Car)Next(A().Provider().GetStoredObjects(typeof(Car)).GetEnumerator());
			car.SetModel("McLaren");
			A().Provider().Update(pilot);
			A().Provider().Update(car);
			A().Provider().Commit();
			StartReplication();
			Assert.AreEqual(2, A().Provider().ObjectsChangedSinceLastReplication().Count);
			pilots = A().Provider().ObjectsChangedSinceLastReplication(typeof(Pilot)).GetEnumerator
				();
			Assert.AreEqual("Terry Jones", ((Pilot)Next(pilots)).Name());
			Assert.IsFalse(pilots.MoveNext());
			cars = A().Provider().ObjectsChangedSinceLastReplication(typeof(Car)).GetEnumerator
				();
			Assert.AreEqual("McLaren", ((Car)Next(cars)).GetModel());
			Assert.IsFalse(cars.MoveNext());
			CommitReplication();
			A().Provider().DeleteAllInstances(typeof(Pilot));
			A().Provider().DeleteAllInstances(typeof(Car));
			A().Provider().Commit();
		}