コード例 #1
0
ファイル: Startup.cs プロジェクト: Redblueflame/ScrapEditor
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add authorization
            // services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)

            var config   = ConfigurationFile.LoadConfiguration("config.json");
            var api      = new ScreenScraperAPI(config);
            var login    = new LoginScreenScraper(api);
            var database = new Database(config);
            var manager  = new ScrapManager(database);
            var scrap    = new Thread(manager.StartScrap);

            Console.WriteLine("Starting scrap thread...");
            scrap.Name = "ScrapThread";
            scrap.Start();
            var mvc = services.AddMvc();

            mvc.AddXmlSerializerFormatters();
            mvc.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddSingleton(typeof(ILoginLogic), login);
            services.AddSingleton(typeof(IDatabase), database);
            services.AddSingleton(typeof(IScrapManager), manager);
            services.AddSingleton(typeof(IScreenScraperAPI), api);
            services.AddSwaggerDocument();
        }
コード例 #2
0
        public void CreateHttpTest()
        {
            _httpTest = new HttpTest();
            _config   = new ConfigurationFile
            {
                DevID       = "PleaseReplaceMe",
                DevPassword = "******",
                SoftName    = "ScrapEditor",
                DBLink      = "http://live-test.ravendb.net",
                DBCertPath  = "none"
            };
            Mock <IScreenScraperAPI> mockAPI = new Mock <IScreenScraperAPI>();

            mockAPI.Setup(t =>
                          t.Login(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(true)
                                                                                     );
            var api = mockAPI.Object;

            //Test with a sucessful login
            _loginValid = new LoginScreenScraper(api);
            _id         = _loginValid.AddUser("UnitTestsUser", "UnitTestsPasswd").Result;
        }