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
        //[Ignore("This test opens a browser window")]
        public void CheckIfTokenCanBeRetrievedFromBrowserLoginPage()
        {
            var loginWindowFactoryMock = new Mock <ILoginWindowFactory>();

            var apiBaseUrl    = "https://localhost:44318/";
            var webAppBaseUrl = "https://localhost:44376/";

            //var apiBaseUrl = "http://guts-api.appspot.com/";
            //var webAppBaseUrl = "http://guts-web.appspot.com/";

            loginWindowFactoryMock.Setup(factory => factory.Create()).Returns(
                () =>
            {
                var httpHandler = new HttpClientToHttpHandlerAdapter(apiBaseUrl);
                return(new LoginWindow(httpHandler, webAppBaseUrl));
            });

            var authorizationHandler = new AuthorizationHandler(loginWindowFactoryMock.Object);

            var retrieveTokenTask = authorizationHandler.RetrieveRemoteAccessTokenAsync();

            var retrievedToken = retrieveTokenTask.Result;

            Assert.That(retrievedToken, Is.Not.Empty);
        }
Exemplo n.º 3
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);
        }