protected MonitoredTestFixtureBaseAttribute(string courseCode)
        {
            _courseCode = courseCode;

            //var executingFolder = new DirectoryInfo(AppContext.BaseDirectory);
            //var projectFolder = executingFolder.Parent?.Parent?.Parent;
            //Assert.That(projectFolder, Is.Not.Null, () => "Technical error: could not find the path of the project.");


            //.SetBasePath(projectFolder.FullName)
            var gutsConfig  = new ConfigurationBuilder().AddJsonFile("gutssettings.json", optional: false).Build();
            var gutsSection = gutsConfig.GetSection("Guts");

            string apiBaseUrl = gutsSection.GetValue("apiBaseUrl", string.Empty);

            if (string.IsNullOrEmpty(apiBaseUrl))
            {
                throw new Exception("Could not find 'apiBaseUrl' setting in 'gutssettings.json'.");
            }

            string webAppBaseUrl = gutsSection.GetValue("webAppBaseUrl", string.Empty);

            if (string.IsNullOrEmpty(webAppBaseUrl))
            {
                throw new Exception("Could not find 'webAppBaseUrl' setting in 'gutssettings.json'.");
            }

            var httpHandler = new HttpClientToHttpHandlerAdapter(apiBaseUrl);

            var authorizationHandler = new AuthorizationHandler(new LoginWindowFactory(httpHandler, webAppBaseUrl));

            _resultSender = new TestRunResultSender(httpHandler, authorizationHandler);
        }
Exemplo n.º 2
0
        protected MonitoredTestFixtureBaseAttribute(string courseCode)
        {
            _courseCode = courseCode;

            string apiBaseUrl = ConfigurationManager.AppSettings["GutsApiUri"];

            if (string.IsNullOrEmpty(apiBaseUrl))
            {
                throw new ConfigurationErrorsException("Could not find an appsetting 'GutsApiUri' that contains a valid Api url.");
            }

            var httpHandler = new HttpClientToHttpHandlerAdapter(apiBaseUrl);

            var authorizationHandler = new AuthorizationHandler(new LoginWindowFactory(httpHandler));

            _resultSender = new TestRunResultSender(httpHandler, authorizationHandler);
        }