Example #1
0
        public static void Run(params string[] args)
        {
            var logger = LoggerFactory();

            var config = new ElevatorConfiguration();
            var optionSet = new OptionSet();
            optionSet.Add("up", option =>
            {
                config.Direction = option;
            });
            optionSet.Add("assembly=", option =>
            {
                config.AssemblyIsSpecified = true;
                config.AssemblyName = option;
            });
            optionSet.Parse(args);

            if (string.IsNullOrEmpty(config.Direction))
            {
                logger.Log("You have to specify direction:");
                logger.Log("\tElevator.exe -up, for going up");
                logger.Log("\tElevator.exe -down, for going down (not supported yet)");
            }
            else if (!config.AssemblyIsSpecified)
            {
                logger.Log("You have to specify migration assembly:");
                logger.Log("\tElevator.exe -up -assembly:name.dll");
            }

            if (config.IsValid())
            {
                var migrationAssembly = Assembly.LoadFrom(Path.Combine(Environment.CurrentDirectory, config.AssemblyName));
                var levelDataStorageClasses = new LevelDataStorageClassFinder().Find(migrationAssembly);
                if (levelDataStorageClasses.Any())
                {
                    var levelDataStorage = Activator.CreateInstance(levelDataStorageClasses.First()) as ILevelDataStorage;
                    levelDataStorage.Initialize();

                    var levelsCalsses = new ElevatorLevelClassFinder().Find(migrationAssembly);
                    var levelFactory = new LevelFactory();
                    var levels = new List<Level>();

                    foreach (var levelClass in levelsCalsses)
                    {
                        levels.Add(levelFactory.NewLevel(levelClass));
                    }

                    var elevator = new Lift(new ConsoleLogger(), levelDataStorage);
                    elevator.AddLevel(levels.ToArray());
                    elevator.Start();
                    elevator.Top();
                }
                else
                {
                    logger.Log("Could not find a class in assembly 'Tests.Empty.dll' that implements the ILevelDataStorage interface.");
                }
            }
        }
Example #2
0
 public void Setup()
 {
     mocked = new LiftWithMocks();
     mocked.storage.StubHasStoredLevelInfoAndReturn(false);
     lift = mocked.liftWithFakes;
 }
Example #3
0
 public LiftWithMocks()
 {
     logger = new LoggerMock();
     storage = new LevelDataStorageMock();
     liftWithFakes = new Lift(logger, storage);
 }