Exemplo n.º 1
0
        public void TestLog()
        {
            IBasicLogger logger1     = Substitute.For <IBasicLogger>();
            IBasicLogger logger2     = Substitute.For <IBasicLogger>();
            LogSplitter  logSplitter = new LogSplitter(logger1, logger2);

            logSplitter.Log(LogType.Log, "some stuff");
            logger1.Received().Log(LogType.Log, "some stuff");
            logger2.Received().Log(LogType.Log, "some stuff");
        }
Exemplo n.º 2
0
        public void TestLog__MessageNull()
        {
            LogSplitter           logSplitter = new LogSplitter(Substitute.For <IBasicLogger>(), Substitute.For <IBasicLogger>());
            ArgumentNullException ex          = Assert.Throws <ArgumentNullException>(delegate
            {
                logSplitter.Log(null);
            });

            Assert.Equal("message", ex.ParamName);
        }
Exemplo n.º 3
0
        public void TestException()
        {
            IBasicLogger logger1     = Substitute.For <IBasicLogger>();
            IBasicLogger logger2     = Substitute.For <IBasicLogger>();
            LogSplitter  logSplitter = new LogSplitter(logger1, logger2);
            Exception    ex          = new Exception();

            logSplitter.Exception("some stuff", ex);
            logger1.Received().Exception("some stuff", ex);
            logger2.Received().Exception("some stuff", ex);
        }
Exemplo n.º 4
0
        public void TestLog()
        {
            IBasicLogger logger1     = Substitute.For <IBasicLogger>();
            IBasicLogger logger2     = Substitute.For <IBasicLogger>();
            LogSplitter  logSplitter = new LogSplitter(logger1, logger2);
            ILogMessage  message     = Substitute.For <ILogMessage>();

            logSplitter.Log(message);
            logger1.Received().Log(message);
            logger2.Received().Log(message);
        }
Exemplo n.º 5
0
        public ReaderMtgaOutputLog(
            LogSplitter logSplitter,
            Util util,
            IPossibleDateFormats dateFormatsProvider,
            ReaderMtgaOutputLogUnityCrossThreadLogger readerCrossThreadLogger,
            ReaderMtgaOutputLogGre readerGRE,
            ReaderDetailedLogs readerDetailedLogs,
            ReaderMessageSummarized converterMessageSummarized,
            ReaderAccountsClient readerAccountsClient,
            MtgaOutputLogResultsPreparer2 preparer2,
            OutputLogMessagesBatcher outputLogMessagesBatcher)
        {
            this.logSplitter = logSplitter;
            this.util        = util;
            dateFormats      = dateFormatsProvider.Formats;

            //this.preparer = preparer;
            this.preparer2 = preparer2;

            this.outputLogMessagesBatcher = outputLogMessagesBatcher;

            // Handled
            converters.Add(PREFIX_CROSSTHREADLOGGER, readerCrossThreadLogger);
            converters.Add(PREFIX_CLIENT_GRE, readerGRE);
            converters.Add(PREFIX_DETAILED_LOGS, readerDetailedLogs);

            // Ignored
            converters.Add(PREFIX_CLEANUP, new ReaderIgnored());
            converters.Add(PREFIX_ACCOUNTS_STARTUP, new ReaderIgnored());
            converters.Add(PREFIX_ACCOUNTS_CLIENT, readerAccountsClient);
            converters.Add(PREFIX_STORE_AUTH_GETSKUS, new ReaderIgnored());
            converters.Add(PREFIX_STORE_GETSKUS, new ReaderIgnored());
            converters.Add(PREFIX_SOCIAL_CONTROLLER, new ReaderIgnored());
            converters.Add(PREFIX_DISCORD, new ReaderIgnored());
            converters.Add(PREFIX_ACCOUNTS_SHAREDCONTEXTVIEW, new ReaderIgnored());
            converters.Add(PREFIX_ACCOUNTS_LOGIN, new ReaderIgnored());
            converters.Add(PREFIX_MESSAGESUMMARIZED, converterMessageSummarized);
            converters.Add(PREFIX_URLAPI, new ReaderIgnored());
            converters.Add(PREFIX_EOSCLIENT, new ReaderIgnored());
            converters.Add(PREFIX_WIZARDS_PLATFORM_SDK, new ReaderIgnored());
            converters.Add("Accounts - AccountClient", new ReaderIgnored());
            converters.Add("Social", new ReaderIgnored());

            // Everything else ends up as Unknown
        }
        public MainWindow(
            ConfigModel configApp,
            ICollection <Card> allCards,
            MainWindowVM viewModel,
            ProcessMonitor processMonitor,
            LogFileZipper zipper,
            ServerApiCaller api,
            StartupShortcutManager startupManager,
            LogSplitter logSplitter,
            MtgaResourcesLocator resourcesLocator,
            FileMonitor fileMonitor,
            DraftCardsPicker draftHelper,
            ReaderMtgaOutputLog readerMtgaOutputLog,
            InGameTracker2 inMatchTracker,
            ExternalProviderTokenManager tokenManager,
            PasswordHasher passwordHasher,
            CacheSingleton <Dictionary <string, DraftRatings> > draftRatings,
            DraftHelperRunner draftHelperRunner)
        {
            // Set the config model reference
            ConfigModel = configApp;


            Reader = readerMtgaOutputLog;
            processMonitor.OnProcessMonitorStatusChanged += OnProcessMonitorStatusChanged;
            Zipper           = zipper;
            Api              = api;
            StartupManager   = startupManager;
            LogSplitter      = logSplitter;
            ResourcesLocator = resourcesLocator;
            FileMonitor      = fileMonitor;
            fileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText;
            DraftHelper = draftHelper;
            //this.logProcessor = logProcessor;
            InGameTracker     = inMatchTracker;
            TokenManager      = tokenManager;
            PasswordHasher    = passwordHasher;
            DraftRatings      = draftRatings;
            DraftHelperRunner = draftHelperRunner;
            ResourcesLocator.LocateLogFilePath(ConfigModel);
            ResourcesLocator.LocateGameClientFilePath(ConfigModel);

            fileMonitor.SetFilePath(ConfigModel.LogFilePath);

            // Set the view model
            MainWindowVM = viewModel;

            // Set the data context to the view model
            DataContext = MainWindowVM;

            InitializeComponent();

            WelcomeControl.Init(tokenManager);
            PlayingControl.Init(MainWindowVM);
            StatusBarTop.Init(this, MainWindowVM);
            ReadyControl.Init(ConfigModel.GameFilePath);
            DraftingControl.Init(allCards, MainWindowVM.DraftingVM);

            DraftingControl.SetPopupRatingsSource(ConfigModel.ShowLimitedRatings, ConfigModel.ShowLimitedRatingsSource);

            processMonitor.Start(new System.Threading.CancellationToken());

            FileMonitor.Start(new System.Threading.CancellationToken());

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            timer.Tick += (sender, e) =>
            {
                MainWindowVM.SetCardsDraftFromBuffered();
                MainWindowVM.SetCardsInMatchTrackingFromBuffered();
            };
            timer.Start();

            var timerTokenRefresh = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(9)
            };

            timerTokenRefresh.Tick += (sender, e) =>
            {
                RefreshAccessToken();
            };
            timerTokenRefresh.Start();
        }
Exemplo n.º 7
0
        public MainWindow(
            //OptionsWindow optionsWindow,
            IOptionsMonitor <ConfigModelApp> configApp,
            ICollection <Card> allCards,
            MainWindowVM viewModel,
            ProcessMonitor processMonitor,
            LogFileZipper zipper,
            ServerApiCaller api,
            StartupShortcutManager startupManager,
            LogSplitter logSplitter,
            MtgaResourcesLocator resourcesLocator,
            FileMonitor fileMonitor,
            DraftHelper draftHelper,
            //LogProcessor logProcessor,
            ReaderMtgaOutputLog readerMtgaOutputLog,
            //CacheSingleton<ICollection<Card>> allCards,
            InGameTracker inMatchTracker,
            ExternalProviderTokenManager tokenManager,
            PasswordHasher passwordHasher,
            NotifyIconManager notifyIconManager,
            CacheSingleton <Dictionary <string, DraftRatings> > draftRatings
            )
        {
            this.configApp = configApp.CurrentValue;
            //optionsWindow.Init(this.configApp);
            //optionsWindow.Owner = Window.GetWindow(this);
            //this.optionsWindow = optionsWindow;

            this.reader         = readerMtgaOutputLog;
            this.processMonitor = processMonitor;
            processMonitor.OnProcessMonitorStatusChanged += OnProcessMonitorStatusChanged;
            this.zipper           = zipper;
            this.api              = api;
            this.startupManager   = startupManager;
            this.logSplitter      = logSplitter;
            this.resourcesLocator = resourcesLocator;
            this.fileMonitor      = fileMonitor;
            fileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText;
            this.draftHelper = draftHelper;
            //this.logProcessor = logProcessor;
            this.inGameTracker     = inMatchTracker;
            this.tokenManager      = tokenManager;
            this.passwordHasher    = passwordHasher;
            this.notifyIconManager = notifyIconManager;
            this.draftRatings      = draftRatings;
            this.resourcesLocator.LocateLogFilePath(this.configApp);
            this.resourcesLocator.LocateGameClientFilePath(this.configApp);

            fileMonitor.SetFilePath(this.configApp.LogFilePath);
            //viewModel.ValidateUserId(this.configApp.UserId);
            viewModel.Opacity = this.configApp.Opacity;
            vm          = viewModel;
            DataContext = vm;

            InitializeComponent();

            ucWelcome.Init(tokenManager);
            ucPlaying.Init(vm, this.configApp.WindowSettingsOpponentCards);

            //trayIcon = new System.Windows.Forms.NotifyIcon { Text = "MTGAHelper Tracker" };
            //trayIcon.Icon = new System.Drawing.Icon(Application.GetResourceStream(new Uri("pack://application:,,,/Assets/Images/wcC.ico")).Stream);
            //trayIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(TrayIcon_MouseClick);
            //trayIcon.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[]
            //{
            //    new System.Windows.Forms.MenuItem("Quit", new EventHandler(TrayIcon_Quit))
            //});

            statusBarTop.Init(this, vm /*, draftHelper, logProcessor, this.configApp.UserId,*/);
            ucReady.Init(this.configApp.GameFilePath);
            ucDraftHelper.Init(allCards, vm.DraftingVM);
            //ucPlaying.Init(vm);

            ucDraftHelper.SetPopupRatingsSource(this.configApp.ShowLimitedRatings, this.configApp.ShowLimitedRatingsSource);

            this.processMonitor.Start(new System.Threading.CancellationToken());
            this.fileMonitor.Start(new System.Threading.CancellationToken());

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            timer.Tick += (object sender, EventArgs e) =>
            {
                vm.SetCardsDraftFromBuffered();
                vm.SetCardsInMatchTrackingFromBuffered();
            };
            timer.Start();

            var timerTokenRefresh = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(9)
            };

            timerTokenRefresh.Tick += (object sender, EventArgs e) =>
            {
                RefreshAccessToken();
            };
            timerTokenRefresh.Start();
        }