Beispiel #1
0
        public FleetTest()
        {
            AppDomain.CurrentDomain.SetRepositoryFactory(() => RepositoryInstance);
            var validators = new VehicleValidatorCollection().ChassisIsRequired().CheckNumberOfPassagers().ColorIsRequired();

            fleetManager = new FleetManager(validators);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            RepositoryService.RegisterDefaultRepository();
            var          validators   = new VehicleValidatorCollection().ChassisIsRequired().CheckNumberOfPassagers().ColorIsRequired();
            FleetManager fleetManager = new FleetManager(validators);
            Menu         menu         = new Menu();

            menu.Add("Insert a new vehicle", (context) => { context.NavigateTo(new InsertVehiclePage(fleetManager)); });
            menu.Add("Edit an existing vehicle", (context) => { context.NavigateTo(new EditVehiclePage(fleetManager)); });
            menu.Add("Delete an existing vehicle", (context) => { context.NavigateTo(new DeleteVehiclePage(fleetManager)); });
            menu.Add("List all vehicles", (context) => { context.NavigateTo(new ListVehiclesPage(fleetManager)); });
            menu.Add("Find vehicle by chassis id", (context) => { context.NavigateTo(new VehicleDetailsPage(fleetManager)); });
            menu.Add("Exit", (context) => { context.Exit(); });
            menu.Display();
        }
        public void When_add_custom_validator_should_be_executed()
        {
            bool executed = false;

            Collection = Collection.AddCustomValidator((vehicle) =>
            {
                executed = true;
                return(Core.Validation.Success);
            });
            var result = Collection.Result(new CustomVehicle()
            {
                Color     = "Red",
                ChassisId = new Core.Domain.Chassis()
                {
                    ChassisNumber = 123, ChassisSeries = "abc123"
                },
                Type = Core.Domain.VehicleType.Bus,
                NumberOfPassagers = 42
            });

            Assert.True(executed, "The custom validator was not executed");
        }
 public ValidatorTest()
 {
     Collection = Collection.ChassisIsRequired().CheckNumberOfPassagers().ColorIsRequired();
 }