public void TruckEngineTest() { var truck = new Truck { Id = "1" }; var personCar = new PersonCar { Id = "2" }; var carPark = new CarPark { Cars = new ObservableCollection <Car> { truck, personCar } }; MEFValidationRules.RegisterType(typeof(TruckEngineValidator)); var gr = carPark.EntityGraph(CarPark.Shape); Assert.IsFalse(truck.HasValidationErrors); Assert.IsFalse(truck.Engine.HasValidationErrors); truck.Engine.EngineType = EngineType.Benzin; Assert.IsTrue(truck.HasValidationErrors); Assert.IsFalse(truck.Engine.HasValidationErrors); truck.Engine.EngineType = EngineType.Diesel; Assert.IsFalse(truck.HasValidationErrors); Assert.IsFalse(truck.Engine.HasValidationErrors); MEFValidationRules.UnregisterType(typeof(TruckEngineValidator)); }
public void UniqIdsTest() { var truck = new Truck { Id = "1" }; var personCar = new PersonCar { Id = "2" }; var carPark = new CarPark { Cars = new ObservableCollection <Car> { truck, personCar } }; MEFValidationRules.RegisterType(typeof(UniqIds)); var gr = carPark.EntityGraph(CarPark.Shape); Assert.IsFalse(truck.HasValidationErrors); Assert.IsFalse(personCar.HasValidationErrors); truck.Id = "2"; Assert.IsTrue(truck.HasValidationErrors); Assert.IsTrue(personCar.HasValidationErrors); personCar.Id = "1"; Assert.IsFalse(truck.HasValidationErrors); Assert.IsFalse(personCar.HasValidationErrors); MEFValidationRules.UnregisterType(typeof(UniqIds)); }
public void TruckEquipmentTest() { var truck = new Truck { Id = "1" }; var personCar = new PersonCar { Id = "2" }; var carPark = new CarPark { Cars = new ObservableCollection <Car> { truck, personCar } }; MEFValidationRules.RegisterType(typeof(TruckDoorsValidator)); var gr = carPark.EntityGraph(CarPark.Shape); Assert.IsFalse(truck.HasValidationErrors); truck.Doors.Add(new Door()); Assert.IsTrue(truck.HasValidationErrors); MEFValidationRules.UnregisterType(typeof(TruckDoorsValidator)); }