Esempio n. 1
0
        public IntegrationTestEnvironment(ICacheContainer cacheContainer,
                                          NPath repoPath,
                                          NPath solutionDirectory,
                                          CreateEnvironmentOptions options = null,
                                          bool enableTrace          = false,
                                          bool initializeRepository = true)
        {
            this.enableTrace = enableTrace;

            options = options ?? new CreateEnvironmentOptions(NPath.SystemTemp.Combine(ApplicationInfo.ApplicationName, "IntegrationTests"));

            defaultEnvironment = new DefaultEnvironment(cacheContainer);
            defaultEnvironment.FileSystem.SetCurrentDirectory(repoPath);

            var environmentPath = options.UserProfilePath;

            LocalAppData    = environmentPath.Combine("User");
            UserCachePath   = LocalAppData.Combine("Cache");
            CommonAppData   = environmentPath.Combine("System");
            SystemCachePath = CommonAppData.Combine("Cache");

            var installPath = solutionDirectory.Parent.Parent.Parent.Combine("src", "com.unity.git.api", "Api");

            Initialize(UnityVersion, installPath, solutionDirectory, NPath.Default, repoPath.Combine("Assets"));

            InitializeRepository(initializeRepository ? (NPath?)repoPath : null);

            GitDefaultInstallation = new GitInstaller.GitInstallDetails(UserCachePath, this);

            if (enableTrace)
            {
                logger.Trace("EnvironmentPath: \"{0}\" SolutionDirectory: \"{1}\" ExtensionInstallPath: \"{2}\"",
                             environmentPath, solutionDirectory, ExtensionInstallPath);
            }
        }
Esempio n. 2
0
        private DefaultEnvironment GetEnvironmentWith10Chromosomes()
        {
            var environment = new DefaultEnvironment();

            environment.UpdateEnvierment(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }.ToChromosomes(), 1);
            return(environment);
        }
Esempio n. 3
0
        public void OneTimeSetup()
        {
            Logging.LogAdapter = new ConsoleLogAdapter();
            //Logging.TracingEnabled = true;
            TaskManager = new TaskManager();
            var syncContext = new ThreadSynchronizationContext(Token);

            TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext);

            var env = new DefaultEnvironment();

            TestBasePath = NPath.CreateTempDirectory("integration-tests");
            env.FileSystem.SetCurrentDirectory(TestBasePath);

            var repo = Substitute.For <IRepository>();

            repo.LocalPath.Returns(TestBasePath);
            env.Repository = repo;

            var platform = new Platform(env);

            ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token);
            var processEnv = platform.GitEnvironment;
            var path       = new ProcessTask <NPath>(TaskManager.Token, new FirstLineIsPathOutputProcessor())
                             .Configure(ProcessManager, env.IsWindows ? "where" : "which", "git")
                             .Start().Result;

            env.GitExecutablePath = path ?? "git".ToNPath();
        }
Esempio n. 4
0
    private void InitGitClient()
    {
        Debug.Log("Custom Git Window Started");
        if (gitClient == null)
        {
            var    cacheContainer           = new CacheContainer();
            var    defaultEnvironment       = new DefaultEnvironment(cacheContainer);
            string unityAssetsPath          = null;
            string unityApplicationContents = null;
            string unityVersion             = null;
            NPath  extensionInstallPath     = default(NPath);
            if (unityApplication == null)
            {
                unityAssetsPath          = Application.dataPath;
                unityApplication         = EditorApplication.applicationPath;
                unityApplicationContents = EditorApplication.applicationContentsPath;
                extensionInstallPath     = DetermineInstallationPath();
                unityVersion             = Application.unityVersion;
            }

            defaultEnvironment.Initialize(unityVersion, extensionInstallPath, unityApplication.ToNPath(),
                                          unityApplicationContents.ToNPath(), unityAssetsPath.ToNPath());

            var taskManager        = new TaskManager();
            var processEnvironment = new ProcessEnvironment(defaultEnvironment);
            var processManager     = new ProcessManager(defaultEnvironment, processEnvironment, taskManager.Token);

            gitClient = new GitClient(defaultEnvironment, processManager, taskManager.Token);
        }
    }
Esempio n. 5
0
        /// <summary>
        /// Creates the instance.
        /// </summary>
        /// <param name="host">caller <see cref="ITemplateEngineHost"/>.</param>
        /// <param name="virtualizeConfiguration">if true, settings will be stored in memory and will be disposed with instance.</param>
        /// <param name="loadDefaultComponents">if true, the default components (providers, installers, generator) will be loaded. Same as calling <see cref="LoadDefaultComponents()"/> after instance is created.</param>
        /// <param name="hostSettingsLocation">the file path to store host specific settings. Use null for default location.
        /// Note: this parameter changes only directory of host and host version specific settings. Global settings path remains unchanged.</param>
        public Bootstrapper(ITemplateEngineHost host, bool virtualizeConfiguration, bool loadDefaultComponents = true, string?hostSettingsLocation = null)
        {
            _host = host ?? throw new ArgumentNullException(nameof(host));

            if (string.IsNullOrWhiteSpace(hostSettingsLocation))
            {
                _engineEnvironmentSettings = new EngineEnvironmentSettings(host, virtualizeSettings: virtualizeConfiguration);
            }
            else
            {
                string       hostSettingsDir        = Path.Combine(hostSettingsLocation, host.HostIdentifier);
                string       hostVersionSettingsDir = Path.Combine(hostSettingsLocation, host.HostIdentifier, host.Version);
                IEnvironment environment            = new DefaultEnvironment();
                IPathInfo    pathInfo = new DefaultPathInfo(environment, host, hostSettingsDir: hostSettingsDir, hostVersionSettingsDir: hostVersionSettingsDir);
                _engineEnvironmentSettings = new EngineEnvironmentSettings(
                    host,
                    virtualizeSettings: virtualizeConfiguration,
                    environment: environment,
                    pathInfo: pathInfo);
            }

            _templateCreator         = new TemplateCreator(_engineEnvironmentSettings);
            _templatePackagesManager = new Edge.Settings.TemplatePackageManager(_engineEnvironmentSettings);
            if (loadDefaultComponents)
            {
                LoadDefaultComponents();
            }
        }
 public WallsAndLinesDemoBrainTests()
 {
     map         = TestMap1Factory.Create();
     environment = new DefaultEnvironment(map);
     robot       = new LineAndWallDetectorRobot(environment, 50);
     brain       = new WallsAndLinesDemoBrain(robot);
 }
Esempio n. 7
0
        public void OneTimeSetup()
        {
            GitHub.Unity.Guard.InUnitTestRunner = true;
            LogHelper.LogAdapter = new MultipleLogAdapter(new FileLogAdapter($"..\\{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}-tasksystem-tests.log"));
            //LogHelper.TracingEnabled = true;
            TaskManager = new TaskManager();
            var syncContext = new ThreadSynchronizationContext(Token);

            TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext);

            var env = new DefaultEnvironment(new CacheContainer());

            TestBasePath = NPath.CreateTempDirectory("integration tests");
            env.FileSystem.SetCurrentDirectory(TestBasePath);
            env.Initialize("5.6", TestBasePath, TestBasePath, TestBasePath, TestBasePath.Combine("Assets"));

            var repo = Substitute.For <IRepository>();

            repo.LocalPath.Returns(TestBasePath);
            env.Repository = repo;

            var platform = new Platform(env);

            ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token);
            var processEnv = platform.GitEnvironment;
            var installer  = new GitInstaller(env, ProcessManager, TaskManager.Token);
            var state      = installer.FindSystemGit(new GitInstaller.GitInstallationState());

            env.GitInstallationState = state;
        }
        public static List<Mock> MockUtilities()
        {
            var mocks = new List<Mock>();
            var userContext = new Mock<IUserContext>();
            userContext.Setup(m => m.Id).Returns(CurrentUserId);
            userContext.Setup(m => m.GroupId).Returns(CurrentUserCurrentGroupId);
            mocks.Add(userContext);
            StrixPlatform.User = userContext.Object;

            var environment = new DefaultEnvironment();
            StrixPlatform.Environment = environment;

            var dependencyInjectorMock = new Mock<IDependencyInjector>();
            DependencyInjector.Injector = dependencyInjectorMock.Object;
            dependencyInjectorMock.Setup(d => d.TryGet<IMembershipService>()).Returns((IMembershipService)null);
            mocks.Add(dependencyInjectorMock);

            var entityHelper = new Mock<IEntityHelper>();
            EntityHelper.SetHelper(entityHelper.Object);
            mocks.Add(entityHelper);

            var platformHelperMock = new Mock<IPlatformHelper>();
            mocks.Add(platformHelperMock);
            StrixCms.SetHelper(platformHelperMock.Object);

            return mocks;
        }
        static void Main(string[] args)
        {
            // Create a LoggerFactory responsible for internal logging
            var loggerFactory = LoggerFactory.Create(builder => builder
                                                     .SetMinimumLevel(LogLevel.Debug)
                                                     .AddConsole());

            var logger = loggerFactory.CreateLogger("Main");

            // Manually setup the configuration for the library
            var configuration = new Configuration
            {
                ServiceName         = "DemoApp",
                ServiceType         = "ConsoleApp",
                LogGroupName        = "DemoApp",
                EnvironmentOverride = Environments.EC2,
                AgentEndPoint       = "tcp://127.0.0.1:25888"
            };

            // create the logger using a DefaultEnvironment which will write over TCP
            var environment = new DefaultEnvironment(configuration, loggerFactory);
            var metrics     = new MetricsLogger(environment, loggerFactory);

            for (int i = 0; i < 10; i++)
            {
                EmitMetrics(logger, metrics);
            }

            logger.LogInformation("Shutting down");

            environment.Sink.Shutdown().Wait(TimeSpan.FromSeconds(120));
        }
Esempio n. 10
0
        public IntegrationTestEnvironment(ICacheContainer cacheContainer,
                                          NPath repoPath,
                                          NPath solutionDirectory,
                                          NPath environmentPath     = null,
                                          bool enableTrace          = false,
                                          bool initializeRepository = true)
        {
            defaultEnvironment = new DefaultEnvironment(cacheContainer);
            defaultEnvironment.FileSystem.SetCurrentDirectory(repoPath);
            environmentPath = environmentPath ??
                              defaultEnvironment.GetSpecialFolder(Environment.SpecialFolder.LocalApplicationData)
                              .ToNPath()
                              .EnsureDirectoryExists(ApplicationInfo.ApplicationName + "-IntegrationTests");

            integrationTestEnvironmentPath = environmentPath;
            UserCachePath   = integrationTestEnvironmentPath.Combine("User");
            SystemCachePath = integrationTestEnvironmentPath.Combine("System");

            var installPath = solutionDirectory.Parent.Parent.Combine("src", "GitHub.Api");

            Initialize(UnityVersion, installPath, solutionDirectory, repoPath.Combine("Assets"));

            if (initializeRepository)
            {
                InitializeRepository();
            }

            this.enableTrace = enableTrace;

            if (enableTrace)
            {
                logger.Trace("EnvironmentPath: \"{0}\" SolutionDirectory: \"{1}\" ExtensionInstallPath: \"{2}\"",
                             environmentPath, solutionDirectory, ExtensionInstallPath);
            }
        }
Esempio n. 11
0
        public IntegrationTestEnvironment(ICacheContainer cacheContainer,
                                          NPath repoPath,
                                          NPath solutionDirectory,
                                          NPath?environmentPath     = null,
                                          bool enableTrace          = false,
                                          bool initializeRepository = true)
        {
            defaultEnvironment = new DefaultEnvironment(cacheContainer);

            defaultEnvironment.FileSystem.SetCurrentDirectory(repoPath);
            environmentPath = environmentPath ??
                              defaultEnvironment.UserCachePath.EnsureDirectoryExists("IntegrationTests");

            UserCachePath   = environmentPath.Value.Combine("User");
            SystemCachePath = environmentPath.Value.Combine("System");

            var installPath = solutionDirectory.Parent.Parent.Combine("src", "GitHub.Api");

            Initialize(UnityVersion, installPath, solutionDirectory, NPath.Default, repoPath.Combine("Assets"));

            InitializeRepository(initializeRepository ? (NPath?)repoPath : null);

            this.enableTrace = enableTrace;

            if (enableTrace)
            {
                logger.Trace("EnvironmentPath: \"{0}\" SolutionDirectory: \"{1}\" ExtensionInstallPath: \"{2}\"",
                             environmentPath, solutionDirectory, ExtensionInstallPath);
            }
        }
Esempio n. 12
0
        public static List <Mock> MockUtilities()
        {
            var mocks       = new List <Mock>();
            var userContext = new Mock <IUserContext>();

            userContext.Setup(m => m.Id).Returns(CurrentUserId);
            userContext.Setup(m => m.GroupId).Returns(CurrentUserCurrentGroupId);
            mocks.Add(userContext);
            StrixPlatform.User = userContext.Object;

            var environment = new DefaultEnvironment();

            StrixPlatform.Environment = environment;

            var dependencyInjectorMock = new Mock <IDependencyInjector>();

            DependencyInjector.Injector = dependencyInjectorMock.Object;
            dependencyInjectorMock.Setup(d => d.TryGet <IMembershipService>()).Returns((IMembershipService)null);
            mocks.Add(dependencyInjectorMock);

            var entityHelper = new Mock <IEntityHelper>();

            EntityHelper.SetHelper(entityHelper.Object);
            mocks.Add(entityHelper);

            var platformHelperMock = new Mock <IPlatformHelper>();

            mocks.Add(platformHelperMock);
            StrixCms.SetHelper(platformHelperMock.Object);

            return(mocks);
        }
Esempio n. 13
0
        public void OneTimeSetup()
        {
            GitHub.Unity.Guard.InUnitTestRunner = true;
            LogHelper.LogAdapter = new MultipleLogAdapter(new FileLogAdapter($"..\\{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}-tasksystem-tests.log"));
            //LogHelper.TracingEnabled = true;
            TaskManager = new TaskManager();
            var syncContext = new ThreadSynchronizationContext(Token);

            TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext);

            var env = new DefaultEnvironment();

            TestBasePath = NPath.CreateTempDirectory("integration-tests");
            env.FileSystem.SetCurrentDirectory(TestBasePath);

            var repo = Substitute.For <IRepository>();

            repo.LocalPath.Returns(TestBasePath);
            env.Repository = repo;

            var platform = new Platform(env);

            ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token);
            var processEnv = platform.GitEnvironment;
            var path       = new ProcessTask <NPath>(TaskManager.Token, new FirstLineIsPathOutputProcessor())
                             .Configure(ProcessManager, env.IsWindows ? "where" : "which", "git")
                             .Start().Result;

            env.GitExecutablePath = path.IsInitialized ? path : "git".ToNPath();
        }
Esempio n. 14
0
 public EngineEnvironmentSettings(ITemplateEngineHost host, Func <IEngineEnvironmentSettings, ISettingsLoader> settingsLoaderFactory, string hiveLocation)
 {
     Host           = host;
     Paths          = new DefaultPathInfo(this, hiveLocation);
     Environment    = new DefaultEnvironment();
     SettingsLoader = settingsLoaderFactory(this);
 }
        public void Probe()
        {
            // Arrange
            var configuration = _fixture.Create <IConfiguration>();
            var environment   = new DefaultEnvironment(configuration, NullLoggerFactory.Instance);

            // Act
            var result = environment.Probe();

            // Assert
            Assert.True(result);
        }
        public void Type_Configuration_NotSet()
        {
            // Arrange
            var configuration = _fixture.Create <IConfiguration>();
            var environment   = new DefaultEnvironment(configuration, NullLoggerFactory.Instance);

            // Act
            var typeName = environment.Type;

            // Assert
            Assert.False(string.IsNullOrWhiteSpace(typeName));
        }
        public void LogStreamName_Configuration_NotSet()
        {
            // Arrange
            var configuration = _fixture.Create <IConfiguration>();
            var environment   = new DefaultEnvironment(configuration, NullLoggerFactory.Instance);

            // Act
            var streamName = environment.LogStreamName;

            // Assert
            Assert.Equal(string.Empty, streamName);
        }
Esempio n. 18
0
        public void EnvironmentVariableListShouldBeNullIfEmptyString()
        {
            // Arrange
            const string EnvVarName = "ORYX_TEST_VARIABLE";

            Environment.SetEnvironmentVariable(EnvVarName, "");
            var env = new DefaultEnvironment();

            // Act
            var valueList = env.GetEnvironmentVariableAsList(EnvVarName);

            //Assert
            Assert.Null(valueList);
        }
        public void LogGroupName_Configuration_Set()
        {
            // Arrange
            var logGroupName  = "TestLogGroup";
            var configuration = _fixture.Create <IConfiguration>();

            configuration.LogGroupName = logGroupName;
            var environment = new DefaultEnvironment(configuration, NullLoggerFactory.Instance);

            // Act
            var groupName = environment.LogGroupName;

            // Assert
            Assert.Equal(logGroupName, groupName);
        }
        public void LogStreamName_Configuration_Set()
        {
            // Arrange
            var logStreamName = "TestServiceType";
            var configuration = _fixture.Create <IConfiguration>();

            configuration.LogStreamName.Returns(logStreamName);
            var environment = new DefaultEnvironment(configuration, NullLoggerFactory.Instance);

            // Act
            var streamName = environment.LogStreamName;

            // Assert
            Assert.Equal(logStreamName, streamName);
        }
        public void Type_Configuration_Set()
        {
            // Arrange
            var type          = "TestServiceType";
            var configuration = _fixture.Create <IConfiguration>();

            configuration.ServiceType = type;
            var environment = new DefaultEnvironment(configuration, NullLoggerFactory.Instance);

            // Act
            var typeName = environment.Type;

            // Assert
            Assert.Equal(type, typeName);
        }
    public static void Menu_DownloadLatestDugite()
    {
        LogHelper.LogAdapter = new UnityLogAdapter();

        var unityAssetsPath          = Application.dataPath;
        var unityApplication         = EditorApplication.applicationPath;
        var unityApplicationContents = EditorApplication.applicationContentsPath;
        var extensionInstallPath     = Application.dataPath.ToNPath().Parent;
        var unityVersion             = Application.unityVersion;
        var env = new DefaultEnvironment();

        env.Initialize(unityVersion, extensionInstallPath, unityApplication.ToNPath(),
                       unityApplicationContents.ToNPath(), unityAssetsPath.ToNPath());
        env.InitializeRepository();
        TaskManager.Instance.Initialize(new UnityUIThreadSynchronizationContext());

        var installer = new GitInstaller.GitInstallDetails(env.RepositoryPath, env);
        var manifest  = DugiteReleaseManifest.Load(installer.GitManifest, GitInstaller.GitInstallDetails.GitPackageFeed, env);

        var downloader   = new Downloader();
        var downloadPath = env.RepositoryPath.Combine("downloads");

        foreach (var asset in manifest.Assets)
        {
            downloadPath.Combine(asset.Url.Filename).DeleteIfExists();
            downloader.QueueDownload(asset.Url, downloadPath, retryCount: 3);
        }

        downloader.Progress(p => {
            TaskManager.Instance.RunInUI(() => {
                if (EditorUtility.DisplayCancelableProgressBar(p.Message, p.InnerProgress?.InnerProgress?.Message ?? p.InnerProgress?.Message ?? p.Message,
                                                               p.Percentage))
                {
                    downloader.Cancel();
                }
            });
        }).FinallyInUI((success, ex) => {
            EditorUtility.ClearProgressBar();
            if (success)
            {
                EditorUtility.DisplayDialog("Download done", downloadPath, "Ok");
            }
            else
            {
                EditorUtility.DisplayDialog("Error!", ex.GetExceptionMessageOnly(), "Ok");
            }
        }).Start();
    }
Esempio n. 23
0
        public void EnvironmentVariableListShouldTrimSpaces()
        {
            // Arrange
            const string EnvVarName = "ORYX_TEST_VARIABLE";

            Environment.SetEnvironmentVariable(EnvVarName, "1.3  ,   3.4");
            var env = new DefaultEnvironment();

            // Act
            var valueList = env.GetEnvironmentVariableAsList(EnvVarName);

            //Assert
            Assert.Equal(2, valueList.Count);
            Assert.True(valueList.Contains("1.3"));
            Assert.True(valueList.Contains("3.4"));
        }
Esempio n. 24
0
        public void Should_Compile_And_Run_Source_In_Sandbox()
        {
            var isolator = new AppDomainIsolator();
            var environment = new DefaultEnvironment();

            var source = new CSharpSource("using System; using System.IO; namespace Foo { public class Bar { public int Greet() { return 42; } } }");
            environment.Register(source);

            using (var jail = Jail.Create(isolator, environment))
            {
                dynamic bar = jail.Resolve("Foo.Bar");
                int result = bar.Greet();

                Assert.AreEqual(42, result);
            }
        }
Esempio n. 25
0
        public void Should_Compile_And_Run_Source_In_Sandbox()
        {
            var isolator    = new AppDomainIsolator();
            var environment = new DefaultEnvironment();

            var source = new CSharpSource("using System; using System.IO; namespace Foo { public class Bar { public int Greet() { return 42; } } }");

            environment.Register(source);

            using (var jail = Jail.Create(isolator, environment))
            {
                dynamic bar    = jail.Resolve("Foo.Bar");
                int     result = bar.Greet();

                Assert.AreEqual(42, result);
            }
        }
Esempio n. 26
0
        public void CommonParentTest()
        {
            var environment = new DefaultEnvironment();

            environment.FileSystem = new FileSystem(TestRepoMasterDirtyUnsynchronized);

            var ret = FileSystemHelpers.FindCommonPath(new string[]
            {
                "Assets/Test/Path/file",
                "Assets/Test/something",
                "Assets/Test/Path/another",
                "Assets/alkshdsd",
                "Assets/Test/sometkjh",
            });

            Assert.AreEqual("Assets", ret);
        }
Esempio n. 27
0
        public MainPage()
        {
            this.InitializeComponent();
            environment           = new DefaultEnvironment(new Map(1, 1)); // Did not load the map yet...
            EnvironmentTickSource = new EnvironmentTickSource(environment, SimulationCycleLengthMs);

            var robot = new LineAndWallDetectorRobot(environment);

            Brain = new WallsAndLinesDemoBrain(robot);

            new LogCollector(Brain, this.LogViewModel); // Ctor performs registrations

            this.RobotViewModel = new RobotViewModel(robot);
            RobotImage.Source   = RobotViewModel.Image;

            this.MapViewModel = new MapViewModel();

            InitButtonCommands();
        }
Esempio n. 28
0
            public void Loads_And_Calculates_With_Dynamic_Proxy_In_Separate_AppDomain()
            {
                var isolator = new AppDomainIsolator();

                var environment = new DefaultEnvironment();
                environment.Register("Ext/Calculator.dll");

                using (var jail = Jail.Create(isolator, environment))
                {
                    dynamic calculator = jail.Resolve("Calculator.SimpleCalculator");
                    int result = calculator.Sum(new[] {1, 2, 3, 4, 5});
                    calculator.Name = "simple calculator";

                    Assert.AreEqual(15, result);
                    Assert.AreEqual("simple calculator", calculator.Name);
                }

                Assert.IsFalse(AppDomain.CurrentDomain.GetAssemblies().Any(asm => asm.GetName().Name == "Calculator"));
            }
Esempio n. 29
0
            public void Loads_And_Calculates_With_Dynamic_Proxy_In_Separate_AppDomain()
            {
                var isolator = new AppDomainIsolator();

                var environment = new DefaultEnvironment();

                environment.Register("Ext/Calculator.dll");

                using (var jail = Jail.Create(isolator, environment))
                {
                    dynamic calculator = jail.Resolve("Calculator.SimpleCalculator");
                    int     result     = calculator.Sum(new[] { 1, 2, 3, 4, 5 });
                    calculator.Name = "simple calculator";

                    Assert.AreEqual(15, result);
                    Assert.AreEqual("simple calculator", calculator.Name);
                }

                Assert.IsFalse(AppDomain.CurrentDomain.GetAssemblies().Any(asm => asm.GetName().Name == "Calculator"));
            }
Esempio n. 30
0
        public MainPage()
        {
            this.InitializeComponent();
            environment = new DefaultEnvironment(new Map(1, 1)); // Did not load the map yet...
            var robot = new LineAndWallDetectorRobot(environment, wallSensorMaxDistance: 50);
            var brain = new WallsAndLinesDemoBrain(robot);

            brain.AddCommand(new GenericSingleStateCommand(new FollowingLineState(5.0)));

            this.RobotViewModel = new RobotViewModel(robot);
            RobotImage.Source   = RobotViewModel.Image;

            this.MapViewModel = new MapViewModel();

            SimulationTickTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(500)
            };
            SimulationTickTimer.Tick += SimulationTickTimer_Tick;
        }
        public MainPage()
        {
            this.InitializeComponent();
            environment           = new DefaultEnvironment(new Map(1, 1)); // Did not load the map yet...
            EnvironmentTickSource = new EnvironmentTickSource(environment, SimulationCycleLengthMs);

            var robot = new LineAndWallDetectorRobot(environment);

            Brain = new WallsAndLinesDemoBrain(robot);

            var collector = new LogCollector(Brain, this.LogViewModel);

            this.RobotViewModel = new RobotViewModel(robot);
            RobotImage.Source   = RobotViewModel.Image;

            this.MapViewModel = new MapViewModel();

            FollowLineCommand      = new CommandButtonCommand(Brain, new FollowingLineState(5.0));
            FollowLeftWallCommand  = new CommandButtonCommand(Brain, new FollowingWallOnLeftState());
            FollowRightWallCommand = new CommandButtonCommand(Brain, new FollowingWallOnRightState());
        }