private void AssertUnbound(GarageEntity garage, CarEntity car) { Assert.NotEqual(garage, car.Garage); Assert.False(garage.HasCar(car)); }
public void ManageOneToManyRelation() { var firstCar = new CarEntity("1st Car"); var secondCar = new CarEntity("2nd Car"); var thirdCar = new CarEntity("3d Car"); var originalGarage = new GarageEntity("Original garage"); this.AssertUnbound(originalGarage, firstCar); this.AssertUnbound(originalGarage, secondCar); this.AssertUnbound(originalGarage, thirdCar); originalGarage.AddCar(firstCar); this.AssertBound(originalGarage, firstCar); this.AssertUnbound(originalGarage, secondCar); this.AssertUnbound(originalGarage, thirdCar); originalGarage.AddCar(secondCar); this.AssertBound(originalGarage, firstCar); this.AssertBound(originalGarage, secondCar); this.AssertUnbound(originalGarage, thirdCar); originalGarage.AddCar(thirdCar); this.AssertBound(originalGarage, firstCar); this.AssertBound(originalGarage, secondCar); this.AssertBound(originalGarage, thirdCar); originalGarage.RemoveCar(firstCar); this.AssertUnbound(originalGarage, firstCar); this.AssertBound(originalGarage, secondCar); this.AssertBound(originalGarage, thirdCar); originalGarage.RemoveCar(secondCar); this.AssertUnbound(originalGarage, firstCar); this.AssertUnbound(originalGarage, secondCar); this.AssertBound(originalGarage, thirdCar); originalGarage.RemoveCar(thirdCar); this.AssertUnbound(originalGarage, firstCar); this.AssertUnbound(originalGarage, secondCar); this.AssertUnbound(originalGarage, thirdCar); firstCar.Garage = originalGarage; this.AssertBound(originalGarage, firstCar); this.AssertUnbound(originalGarage, secondCar); this.AssertUnbound(originalGarage, thirdCar); secondCar.Garage = originalGarage; this.AssertBound(originalGarage, firstCar); this.AssertBound(originalGarage, secondCar); this.AssertUnbound(originalGarage, thirdCar); thirdCar.Garage = originalGarage; this.AssertBound(originalGarage, firstCar); this.AssertBound(originalGarage, secondCar); this.AssertBound(originalGarage, thirdCar); var anotherGarage = new GarageEntity("Another garage"); firstCar.Garage = anotherGarage; this.AssertUnbound(originalGarage, firstCar); this.AssertBound(originalGarage, secondCar); this.AssertBound(originalGarage, thirdCar); this.AssertBound(anotherGarage, firstCar); this.AssertUnbound(anotherGarage, secondCar); this.AssertUnbound(anotherGarage, thirdCar); secondCar.Garage = anotherGarage; this.AssertUnbound(originalGarage, firstCar); this.AssertUnbound(originalGarage, secondCar); this.AssertBound(originalGarage, thirdCar); this.AssertBound(anotherGarage, firstCar); this.AssertBound(anotherGarage, secondCar); this.AssertUnbound(anotherGarage, thirdCar); thirdCar.Garage = anotherGarage; this.AssertUnbound(originalGarage, firstCar); this.AssertUnbound(originalGarage, secondCar); this.AssertUnbound(originalGarage, thirdCar); this.AssertBound(anotherGarage, firstCar); this.AssertBound(anotherGarage, secondCar); this.AssertBound(anotherGarage, thirdCar); }
private void AssertBound(GarageEntity garage, CarEntity car) { Assert.Equal(garage, car.Garage); Assert.True(garage.HasCar(car)); }