/// <summary>
        /// 根据指定的数据源加载资源
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private IEnumerable <string> LoadImage(string path)
        {
            DebugMessages.Add(new DebugMessage {
                ActionName = "LoadImage", ActionTime = DateTime.Now.ToString(), ActionMessage = "加载图片"
            });
            List <string> list = null;

            if (Directory.Exists(path))
            {
                DirectoryInfo dirInfo = new DirectoryInfo(path);

                var files = dirInfo.GetFiles(SourceFilter, SearchOption.AllDirectories);

                if (files != null)
                {
                    list = new List <string>();
                    list = (from file in files select file.FullName).ToList();
                }
                Count  = list.Count;
                Values = Enumerable.Range(0, Count);
                Debug.WriteLine("成功加载加载 {0} 图片", Count);
            }
            else
            {
                throw new Exception("无法找到指定路径的资源");
            }

            return(list);
        }
Пример #2
0
        /// <summary>
        /// Checks that a single DEBUG message exists that contains all of the specified strings
        /// </summary>
        public string AssertSingleDebugMessageExists(params string[] expected)
        {
            var matches = DebugMessages.Where(m => expected.All(e => m.Contains(e)));

            matches.Should().ContainSingle("More than one DEBUG message contains the expected strings: {0}", string.Join(",", expected));
            return(matches.First());
        }
Пример #3
0
 public DriverOptions CreateOptions(string testName)
 {
     if (Platform.IsADesktopPlatform())
     {
         DebugMessages.PrintHaveDesktopPlatform();
         return(GetDesktopOptions(Platform, testName));
     }
     //Mobile Platform
     if (Platform.IsAnAppleDevice())
     {
         DebugMessages.PrintHaveApplePlatform();
         return(new AppiumIOSCreator().Create(Platform, testName).GetOpts());
     }
     else
     {
         DebugMessages.PrintHaveAndroidPlatform();
         return(new AppiumAndroidCreator().Create(Platform, testName).GetOpts());
     }
     //return platform.CanUseAppium()
     //    //Mobile Platform
     //    ? platform.IsAnAppleDevice()
     //        ? new AppiumIOSCreator().Create(platform, testName).GetOpts()
     //        : new AppiumAndroidCreator().Create(platform, testName).GetOpts()
     //    //Devolve to WebDriver
     //    : platform.IsAnAppleDevice()
     //        ? new WebDriverIOSCreator().Create(platform, testName).GetCaps()
     //        : new WebDriverAndroidCreator().Create(platform, testName).GetCaps();
 }
        private bool CheckSetup()
        {
            bool setUpCorrectly = true;

            if (buttonBackground == null)
            {
                DebugMessages.LogMissingReferenceError(this, nameof(buttonBackground));
                setUpCorrectly = false;
            }
            if (frame == null)
            {
                DebugMessages.LogMissingReferenceError(this, nameof(frame));
                setUpCorrectly = false;
            }
            else
            {
                if (frame.GetComponent <SpriteRenderer>() == null)
                {
                    DebugMessages.LogComponentNotFoundError(this, nameof(SpriteRenderer), frame.gameObject);
                    setUpCorrectly = false;
                }
            }

            return(setUpCorrectly);
        }
Пример #5
0
 /// <summary>
 /// Assert a message to be sent to a registered debug handler.
 /// </summary>
 /// <param name="message">The message to send.</param>
 internal static void Assert(string message)
 {
     if (DebugMessages != null)
     {
         DebugMessages.Invoke(message);
     }
 }
Пример #6
0
        private async Task DoStart()
        {
            if (GameStatus == GameStatus.Finished)
            {
                gameService.StopGame();

                GameProgress.Clear();
                DebugMessages.Clear();
            }

            GameStatus = GameStatus.Unloaded;

            if (string.IsNullOrWhiteSpace(DllPathInput))
            {
                await NotificationService.Show(Captions.PvB_ErrorMsg_NoDllPath, Captions.ND_OkButtonCaption);

                return;
            }

            if (!File.Exists(DllPathInput))
            {
                await NotificationService.Show($"{Captions.PvB_ErrorMsg_FileDoesNotExist} [{DllPathInput}]",
                                               Captions.ND_OkButtonCaption);

                return;
            }

            Assembly dllToLoad;

            try
            {
                dllToLoad = Assembly.LoadFile(DllPathInput);
            }
            catch
            {
                await NotificationService.Show($"{Captions.PvB_ErrorMsg_FileIsNoAssembly} [{DllPathInput}]",
                                               Captions.ND_OkButtonCaption);

                return;
            }

            var uninitializedBotAndBotName = BotLoader.LoadBot(dllToLoad);

            if (uninitializedBotAndBotName == null)
            {
                await NotificationService.Show($"{Captions.PvB_ErrorMsg_BotCanNotBeLoadedFromAsembly} [{dllToLoad.FullName}]",
                                               Captions.ND_OkButtonCaption);

                return;
            }

            MovesLeft = (Constants.GameConstraint.MaximalMovesPerGame + 1).ToString();
            applicationSettingsRepository.LastUsedBotPath = DllPathInput;
            gameService.CreateGame(uninitializedBotAndBotName.Item1,
                                   uninitializedBotAndBotName.Item2,
                                   new GameConstraints(TimeSpan.FromSeconds(Constants.GameConstraint.BotThinkingTimeSeconds),
                                                       Constants.GameConstraint.MaximalMovesPerGame));

            ((Command)Capitulate).RaiseCanExecuteChanged();
        }
        protected override void BeginProcessing()
        {
            InitializeEventHandlers();
            AzureSession.Instance.ClientFactory.RemoveHandler(typeof(RPRegistrationDelegatingHandler));
            IAzureContext context;

            if (RequireDefaultContext() &&
                TryGetDefaultContext(out context) &&
                context.Account != null &&
                context.Subscription != null)
            {
                AzureSession.Instance.ClientFactory.AddHandler(new RPRegistrationDelegatingHandler(
                                                                   () =>
                {
                    var client = new ResourceManagementClient(
                        context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager),
                        AzureSession.Instance.AuthenticationFactory.GetServiceClientCredentials(context, AzureEnvironment.Endpoint.ResourceManager));
                    client.SubscriptionId = context.Subscription.Id;
                    return(client);
                },
                                                                   s => DebugMessages.Enqueue(s)));
            }

            base.BeginProcessing();
        }
Пример #8
0
 public void addDebugMessage(string title, string text, IItem item = null, IAccount account = null, View view = null, DebugMessage.DebugMessageTypes type = DebugMessage.DebugMessageTypes.General)
 {
     if (AppController.Current != null && (AppController.EnableDebugMessages || OverrideDebugMessages_enableAnyway))
     {
         DebugMessages.Add(new DebugMessage(title, text, item, account, view, type));
     }
 }
        /// <summary>
        /// Checks that a single DEBUG message exists that contains all of the specified strings
        /// </summary>
        public string AssertSingleDebugMessageExists(params string[] expected)
        {
            var matches = DebugMessages.Where(m => expected.All(e => m.Contains(e)));

            Assert.AreNotEqual(0, matches.Count(), "No debug message contains the expected strings: {0}", string.Join(",", expected));
            Assert.AreEqual(1, matches.Count(), "More than one DEBUG message contains the expected strings: {0}", string.Join(",", expected));
            return(matches.First());
        }
Пример #10
0
        protected string ExtractJsonSegment(string json, int startIndex, int endIndex)
        {
            DebugMessages.ExtractJsonSegment(json, startIndex, endIndex);
            var len     = endIndex - startIndex;
            var segment = json.Substring(startIndex, len);

            return(string.Format(SauceryConstants.JSON_SEGMENT_CONTAINER, segment));
        }
Пример #11
0
 /// <summary>
 /// Creates new instance from AzureRMCmdlet and add the RPRegistration handler.
 /// </summary>
 public AzureRMCmdlet()
 {
     AzureSession.ClientFactory.RemoveHandler(typeof(RPRegistrationDelegatingHandler));
     AzureSession.ClientFactory.AddHandler(new RPRegistrationDelegatingHandler(
                                               () => new ResourceManagementClient(
                                                   AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(DefaultContext, AzureEnvironment.Endpoint.ResourceManager),
                                                   DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)),
                                               s => DebugMessages.Enqueue(s)));
 }
Пример #12
0
        public DebugMessages GetDebugMessages()
        {
            if (m_DebugMessages == null || m_DebugMessages.IsDisposed)
            {
                m_DebugMessages = new DebugMessages(this);
                AddLogViewer(m_DebugMessages);
            }

            return(m_DebugMessages);
        }
Пример #13
0
        protected override void BeginProcessing()
        {
            AzureSession.Instance.ClientFactory.RemoveHandler(typeof(RPRegistrationDelegatingHandler));
            AzureSession.Instance.ClientFactory.AddHandler(new RPRegistrationDelegatingHandler(
                                                               () => new ResourceManagementClient(
                                                                   DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager),
                                                                   AzureSession.Instance.AuthenticationFactory.GetServiceClientCredentials(DefaultContext, AzureEnvironment.Endpoint.ResourceManager)),
                                                               s => DebugMessages.Enqueue(s)));

            base.BeginProcessing();
        }
Пример #14
0
        private void FlushDebugMessages(bool record = false)
        {
            if (record)
            {
                RecordDebugMessages();
            }

            string message;

            while (DebugMessages.TryDequeue(out message))
            {
                base.WriteDebug(message);
            }
        }
Пример #15
0
        public WatchWindow()
        {
            DebugMessages = new DebugMessages();
            InitializeComponent();
            itemsGrid.CanUserAddRows = false;
            itemsGrid.CanUserResizeRows = false;

            DebugMessages.CollectionChanged += (sender, args) => {
                if (DebugMessages.Any()) {
                    itemsGrid.ScrollIntoView(DebugMessages.Last());
                }
            };
            Monitor.Start();
        }
Пример #16
0
        public IEBrowserOptions(SaucePlatform platform, string testName) : base(testName)
        {
            Console.WriteLine(SauceOpsConstants.SETTING_UP, testName, SauceOpsConstants.DESKTOP_ON_WEBDRIVER);

            DebugMessages.PrintDesktopOptionValues(platform);

            Console.WriteLine("Creating Internet Explorer Options");
            var o = new InternetExplorerOptions
            {
                PlatformName   = platform.Os,
                BrowserVersion = platform.BrowserVersion
            };

            o.AddAdditionalCapability(SauceOpsConstants.SAUCE_OPTIONS_CAPABILITY, SauceOptions, true);
            Opts = o;
        }
Пример #17
0
        protected virtual void SetupDebuggingTraces()
        {
            _httpTracingInterceptor = _httpTracingInterceptor ?? new
                                      RecordingTracingInterceptor(DebugMessages, _matchers);
            _adalListener = _adalListener ?? new DebugStreamTraceListener(DebugMessages);
            RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
            DebugStreamTraceListener.AddAdalTracing(_adalListener);

            if (AzureSession.Instance.TryGetComponent(nameof(IAzureEventListenerFactory), out IAzureEventListenerFactory factory))
            {
                _azureEventListener = factory.GetAzureEventListener(
                    (message) =>
                {
                    DebugMessages.Enqueue(message);
                });
            }
        }
Пример #18
0
        public AppiumIOSOptions(SaucePlatform platform, string testName) : base(testName)
        {
            Console.WriteLine(SauceOpsConstants.SETTING_UP, testName, SauceOpsConstants.IOS_ON_APPIUM);
            AddSauceLabsOptions(Enviro.SauceNativeApp);

            DebugMessages.PrintiOSOptionValues(platform);

            Console.WriteLine("Creating iOS Options");
            Opts = new SafariOptions()
            {
                BrowserVersion = platform.BrowserVersion,
                PlatformName   = "iOS"
            };
            SauceOptions.Add(SauceOpsConstants.SAUCE_DEVICE_NAME_CAPABILITY, platform.Device);
            SauceOptions.Add(SauceOpsConstants.SAUCE_PLATFORM_VERSION_CAPABILITY, platform.SanitisedLongVersion());
            SauceOptions.Add(SauceOpsConstants.SAUCE_DEVICE_ORIENTATION_CAPABILITY, platform.DeviceOrientation);

            Opts.AddAdditionalCapability(SauceOpsConstants.SAUCE_OPTIONS_CAPABILITY, SauceOptions);
        }
        public AppiumAndroidOptions(SaucePlatform platform, string testName)
            : base(testName)
        {
            Console.WriteLine(SauceOpsConstants.SETTING_UP, testName, SauceOpsConstants.ANDROID_ON_APPIUM);
            var sanitisedLongVersion = platform.SanitisedLongVersion();

            AddSauceLabsOptions(Enviro.SauceNativeApp);

            DebugMessages.PrintAndroidOptionValues(platform, sanitisedLongVersion);

            Console.WriteLine("Creating Android Options");
            Opts = new ChromeOptions();
            Opts.AddAdditionalCapability(SauceOpsConstants.SAUCE_DEVICE_NAME_CAPABILITY, platform.Device);
            Opts.AddAdditionalCapability(SauceOpsConstants.SAUCE_PLATFORM_VERSION_CAPABILITY, sanitisedLongVersion);
            Opts.AddAdditionalCapability(SauceOpsConstants.SAUCE_DEVICE_ORIENTATION_CAPABILITY, platform.DeviceOrientation);
            //Opts.AddAdditionalCapability(SauceOpsConstants.SAUCE_BROWSER_NAME_CAPABILITY, SauceOpsConstants.CHROME_BROWSER);  //Required
            //Opts.AddAdditionalCapability(SauceOpsConstants.SAUCE_PLATFORM_NAME_CAPABILITY, SauceOpsConstants.ANDROID);

            Opts.AddAdditionalCapability(SauceOpsConstants.SAUCE_OPTIONS_CAPABILITY, SauceOptions);
        }
        private bool CheckSetup()
        {
            bool setupCorrect = true;

            if (xAxisWires.Length < 4)
            {
                DebugMessages.LogMissingReferenceError(this, nameof(xAxisWires));
                setupCorrect = false;
            }
            if (yAxisWires.Length < 4)
            {
                DebugMessages.LogMissingReferenceError(this, nameof(yAxisWires));
                setupCorrect = false;
            }
            if (zAxisWires.Length < 4)
            {
                DebugMessages.LogMissingReferenceError(this, nameof(zAxisWires));
                setupCorrect = false;
            }
            if (moveWidgets.Length < 6)
            {
                DebugMessages.LogMissingReferenceError(this, nameof(moveWidgets));
                setupCorrect = false;
            }
            if (scaleWidgets.Length < 8)
            {
                DebugMessages.LogMissingReferenceError(this, nameof(scaleWidgets));
                setupCorrect = false;
            }

            if (content == null)
            {
                DebugMessages.LogMissingReferenceError(this, nameof(content));
                setupCorrect = false;
            }

            return(setupCorrect);
        }
Пример #21
0
 public static void LogDebug(string _message)
 {
     // TODO: look into using string builder to optomise string concatenation
     DebugMessages.Enqueue(GeneratePostMessageText() + _message);
 }
Пример #22
0
 public void Debug(string message, params object[] items)
 {
     DebugMessages.Enqueue(message);
     _logger.Debug(message, items);
 }
        /// <summary>
        /// Checks that at least one DEBUG message exists that contains all of the specified strings
        /// </summary>
        public void AssertDebugMessageExists(params string[] expected)
        {
            IEnumerable <string> matches = DebugMessages.Where(m => expected.All(e => m.Contains(e)));

            matches.Count().Should().NotBe(0, "No DEBUG message contains the expected strings: {0}", string.Join(",", expected));
        }
Пример #24
0
 public void LogDebugLine(string message) => DebugMessages.Add(message);
Пример #25
0
 public void LogDebug(string data)
 {
     Messages.Enqueue(data);
     DebugMessages.Enqueue(data);
     DumpMessage("DEBUG", data);
 }
Пример #26
0
 public void Debug(string message)
 {
     DebugMessages.Add(message);
 }
Пример #27
0
 public void LogDebug(string message, params object[] args)
 {
     DebugMessages.Add(GetFormattedMessage(message, args));
     WriteLine("DEBUG: " + message, args);
 }
Пример #28
0
 public void AssertDebugLogged(string expected)
 {
     DebugMessages.Should().Contain(expected);
 }
Пример #29
0
        /// <summary>
        /// Checks that at least one DEBUG message exists that contains all of the specified strings
        /// </summary>
        public void AssertDebugMessageExists(params string[] expected)
        {
            var matches = DebugMessages.Where(m => expected.All(e => m.Contains(e)));

            matches.Should().NotBeEmpty("No DEBUG message contains the expected strings: {0}", string.Join(",", expected));
        }
        /// <summary>
        /// Checks that at least one DEBUG message exists that contains all of the specified strings
        /// </summary>
        public void AssertDebugMessageExists(params string[] expected)
        {
            var matches = DebugMessages.Where(m => expected.All(e => m.Contains(e)));

            Assert.AreNotEqual(0, matches.Count(), "No DEBUG message contains the expected strings: {0}", string.Join(",", expected));
        }
Пример #31
0
 private void EnqueueDebugSender(object sender, StreamEventArgs args)
 {
     DebugMessages.Enqueue(args.Message);
 }