public void TruckTrailerTest()
        {
            var truck1 = new Truck {
                Id = "1"
            };
            var truck2 = new Truck {
                Id = "2"
            };
            var trailer = new Trailer();
            var carPark = new CarPark
            {
                Cars = new ObservableCollection <Car> {
                    truck1, truck2
                }
            };

            MEFValidationRules.RegisterType(typeof(TruckTrailerValidator));
            var gr = carPark.EntityGraph(CarPark.Shape);

            truck1.Trailer = trailer;
            Assert.IsFalse(truck1.HasValidationErrors);
            Assert.IsFalse(truck2.HasValidationErrors);

            truck2.Trailer = trailer;
            Assert.IsTrue(truck1.HasValidationErrors);
            Assert.IsTrue(truck2.HasValidationErrors);
            MEFValidationRules.UnregisterType(typeof(TruckTrailerValidator));
        }
        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));
        }