Exemple #1
0
        protected async Task <TestResults> RunWorker(Pipelines.AgentJobRequestMessage message,
                                                     [CallerMemberName] string testName = "")
        {
            // Clear working directory
            var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/TestRuns/" + testName;

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            // Fix localization
            var assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var stringFile       = Path.Combine(assemblyLocation, "en-US", "strings.json");

            StringUtil.LoadExternalLocalization(stringFile);

            using (L1HostContext context = new L1HostContext("Agent", GetLogFile(this, testName)))
            {
                SetupMocks(context);

                // Use different working directories for each test
                var config = GetMockedService <FakeConfigurationStore>();
                config.WorkingDirectoryName = testName;

                await SetupMessage(context, message);

                using (var cts = new CancellationTokenSource())
                {
                    cts.CancelAfter((int)JobTimeout.TotalMilliseconds);
                    return(await RunWorker(context, message, cts.Token));
                }
            }
        }
 private void SetupMocks(L1HostContext context)
 {
     _mockedServices.Add(context.SetupService <IConfigurationStore>(typeof(FakeConfigurationStore)));
     _mockedServices.Add(context.SetupService <IJobServer>(typeof(FakeJobServer)));
     _mockedServices.Add(context.SetupService <ITaskServer>(typeof(FakeTaskServer)));
     _mockedServices.Add(context.SetupService <IBuildServer>(typeof(FakeBuildServer)));
     _mockedServices.Add(context.SetupService <IReleaseServer>(typeof(FakeReleaseServer)));
     _mockedServices.Add(context.SetupService <IAgentPluginManager>(typeof(FakeAgentPluginManager)));
     _mockedServices.Add(context.SetupService <ITaskManager>(typeof(FakeTaskManager)));
     _mockedServices.Add(context.SetupService <ICustomerIntelligenceServer>(typeof(FakeCustomerIntelligenceServer)));
 }
        public void SetupL1([CallerMemberName] string testName = "")
        {
            // Clear working directory
            string path = GetWorkingDirectory(testName);

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            // Fix localization
            var assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var stringFile       = Path.Combine(assemblyLocation, "en-US", "strings.json");

            StringUtil.LoadExternalLocalization(stringFile);

            _l1HostContext = new L1HostContext("Agent", GetLogFile(this, testName));
            SetupMocks(_l1HostContext);

            // Use different working directories for each test
            var config = GetMockedService <FakeConfigurationStore>(); // TODO: Need to update this. can hack it for now.

            config.WorkingDirectoryName = testName;
        }