public void TestInitFull()
        {
            DesktopContext context = new DesktopContext()
                                     .SetOsType("OS-X")
                                     .SetOsVersion("10.10.5")
                                     .SetOsServicePack("Yosemite")
                                     .SetOsIs64Bit(true)
                                     .SetDeviceManufacturer("Apple")
                                     .SetDeviceModel("Macbook Pro")
                                     .SetDeviceProcessorCount(4)
                                     .Build();

            Assert.NotNull(context);

            Dictionary <string, object> dict = context.GetData();

            Assert.AreEqual(7, dict.Count);
            Assert.AreEqual("OS-X", dict [Constants.PLAT_OS_TYPE]);
            Assert.AreEqual("10.10.5", dict [Constants.PLAT_OS_VERSION]);
            Assert.AreEqual("Yosemite", dict [Constants.DESKTOP_SERVICE_PACK]);
            Assert.AreEqual(true, dict [Constants.DESKTOP_IS_64_BIT]);
            Assert.AreEqual("Apple", dict [Constants.PLAT_DEVICE_MANU]);
            Assert.AreEqual("Macbook Pro", dict [Constants.PLAT_DEVICE_MODEL]);
            Assert.AreEqual(4, dict [Constants.DESKTOP_PROC_COUNT]);

            Assert.AreEqual("iglu:com.snowplowanalytics.snowplow/desktop_context/jsonschema/1-0-0", context.GetSchema());
            Assert.AreEqual("{\"data\":{\"osVersion\":\"10.10.5\", \"osServicePack\":\"Yosemite\", \"deviceManufacturer\":\"Apple\", \"deviceProcessorCount\":4, \"osIs64Bit\":true, \"deviceModel\":\"Macbook Pro\", \"osType\":\"OS-X\"}, \"schema\":\"iglu:com.snowplowanalytics.snowplow/desktop_context/jsonschema/1-0-0\"}", context.GetJson().ToString());
        }
Пример #2
0
        public WpfApp(DesktopContext context)
            : base(context)
        {
            this.SearchProperties.Add(WpfControl.PropertyNames.Name, "MainWindow");

            this.ClickButton = this.CreateControl <WpfButton>("ClicksBtn");
            this.ClickLabel  = this.CreateControl <WpfText>("ClicksLbl");
        }
Пример #3
0
 public WpfApp(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.Name, "MainWindow");
     
     this.ClickButton = this.CreateControl<WpfButton>("ClicksBtn");
     this.ClickLabel = this.CreateControl<WpfText>("ClicksLbl");
 }
        public void TestInitMinimal()
        {
            DesktopContext context = new DesktopContext().SetOsType("OS-X").SetOsVersion("10.10.5").Build();

            Assert.NotNull(context);

            Dictionary <string, object> dict = context.GetData();

            Assert.AreEqual(2, dict.Count);
            Assert.AreEqual("OS-X", dict [Constants.PLAT_OS_TYPE]);
            Assert.AreEqual("10.10.5", dict [Constants.PLAT_OS_VERSION]);

            Assert.AreEqual("iglu:com.snowplowanalytics.snowplow/desktop_context/jsonschema/1-0-0", context.GetSchema());
            Assert.AreEqual("{\"data\":{\"osVersion\":\"10.10.5\", \"osType\":\"OS-X\"}, \"schema\":\"iglu:com.snowplowanalytics.snowplow/desktop_context/jsonschema/1-0-0\"}", context.GetJson().ToString());
        }
        public void testInitDesktopContext()
        {
            var dc = new DesktopContext()
                     .SetOsType("Windows")
                     .SetOsVersion("10")
                     .SetOsServicePack("6")
                     .SetOsIs64Bit(true)
                     .SetDeviceManufacturer("Asus")
                     .SetDeviceModel("unknown")
                     .SetDeviceProcessorCount(8)
                     .Build();

            Assert.IsNotNull(dc);
            Assert.AreEqual(@"{""schema"":""iglu:com.snowplowanalytics.snowplow/desktop_context/jsonschema/1-0-0"",""data"":{""osType"":""Windows"",""osVersion"":""10"",""osServicePack"":""6"",""osIs64Bit"":true,""deviceManufacturer"":""Asus"",""deviceModel"":""unknown"",""deviceProcessorCount"":8}}", dc.GetJson().ToString());
        }
Пример #6
0
        public void Mutate_UpdateReportTasks()
        {
            IDesktopContext context = new DesktopContext(new DateTime(2018, 1, 1), null, null, "executingAssemblyPath", "ReferenceData", null, null, null)
            {
                KeyValuePairs = new Dictionary <string, object>
                {
                    { ILRContextKeys.ReportTasks, "TestReport" },
                },
            };

            var mutator = new SchemaErrorContextMutator();

            context = mutator.Mutate(context);

            context.KeyValuePairs[ILRContextKeys.ReportTasks].Should().NotBe("TestReport");
            context.KeyValuePairs[ILRContextKeys.ReportTasks].Should().Be(ReportTaskNameConstants.ValidationSchemaErrorReport);
        }
Пример #7
0
        public void TwoPlusTwoEqualsFour_QuickAndDirty()
        {
            var calculator = new DesktopContext().Launch<WinWindow>(@"C:\Windows\system32\calc.exe");
            calculator.SearchProperties.Add(WinWindow.PropertyNames.Name, "Calculator");

            var twoBtn = calculator.CreateControl<WinButton>("2");
            var plusBtn = calculator.CreateControl<WinButton>("Add");
            var equalsBtn = calculator.CreateControl<WinButton>("Equals");
            var resultTxt = calculator.CreateControl<WinText>("Result");

            twoBtn.Click();
            plusBtn.Click();
            twoBtn.Click();
            equalsBtn.Click();

            Assert.AreEqual("4", resultTxt.DisplayText);
        }
Пример #8
0
        public void TwoPlusTwoEqualsFour_QuickAndDirty()
        {
            var calculator = new DesktopContext().Launch <WinWindow>(@"C:\Windows\system32\calc.exe");

            calculator.SearchProperties.Add(WinWindow.PropertyNames.Name, "Calculator");

            var twoBtn    = calculator.CreateControl <WinButton>("2");
            var plusBtn   = calculator.CreateControl <WinButton>("Add");
            var equalsBtn = calculator.CreateControl <WinButton>("Equals");
            var resultTxt = calculator.CreateControl <WinText>("Result");

            twoBtn.Click();
            plusBtn.Click();
            twoBtn.Click();
            equalsBtn.Click();

            Assert.AreEqual("4", resultTxt.DisplayText);
        }
        public void TestInitExceptions()
        {
            DesktopContext context = null;

            try {
                context = new DesktopContext().Build();
            } catch (Exception e) {
                Assert.AreEqual("Desktop Context requires 'osType'.", e.Message);
            }
            Assert.IsNull(context);

            try {
                context = new DesktopContext().SetOsType("OS-X").Build();
            } catch (Exception e) {
                Assert.AreEqual("Desktop Context requires 'osVersion'.", e.Message);
            }
            Assert.IsNull(context);
        }
Пример #10
0
 public WinTabList(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "TabList");
 }
Пример #11
0
 public WinProgressBar(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "ProgressBar");
 }
Пример #12
0
 public WinRowHeader(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "RowHeader");
 }
Пример #13
0
        /// <summary>
        /// Adds the standard NV Pairs to the payload and stitches any available
        /// contexts to the final payload.
        /// </summary>
        /// <param name="payload">The basee event payload</param>
        /// <param name="contexts">The contexts array</param>
        /// <param name="eventId">The event ID</param>
        private void CompleteAndTrackPayload(Payload payload, List <IContext> contexts, string eventId)
        {
            payload.AddDict(_standardNvPairs);

            // Add the subject data if available
            if (_subject != null)
            {
                payload.AddDict(_subject._payload.Payload);
            }

            // Add the session context if available
            if (_clientSession != null)
            {
                contexts.Add(_clientSession.GetSessionContext(eventId));
            }

            // Add the desktop context if available
            if (_desktopContextDelegate != null)
            {
                DesktopContext desktopContext = _desktopContextDelegate.Invoke();
                if (desktopContext != null)
                {
                    contexts.Add(desktopContext);
                }
            }

            // Add the mobile context if available
            if (_mobileContextDelegate != null)
            {
                MobileContext mobileContext = _mobileContextDelegate.Invoke();
                if (mobileContext != null)
                {
                    contexts.Add(mobileContext);
                }
            }

            // Add the geo-location context if available
            if (_geoLocationDelegate != null)
            {
                GeoLocationContext geoLocationContext = _geoLocationDelegate.Invoke();
                if (geoLocationContext != null)
                {
                    contexts.Add(geoLocationContext);
                }
            }

            // Build the final context and it to the payload
            if (contexts != null && contexts.Any())
            {
                var contextArray = new List <Dictionary <string, object> >();
                foreach (IContext context in contexts)
                {
                    contextArray.Add(context.GetJson().Payload);
                }
                var contextEnvelope = new SelfDescribingJson(Constants.SCHEMA_CONTEXTS, contextArray);
                payload.AddJson(contextEnvelope.Payload, _encodeBase64, Constants.CONTEXT_ENCODED, Constants.CONTEXT);
            }

            // Send the payload to the emitter
            if (_synchronous)
            {
                _emitter.Input(payload);
            }
            else
            {
                Task.Factory.StartNew(() => _emitter.Input(payload));
            }
        }
Пример #14
0
 public WpfGroup(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Group");
 }
Пример #15
0
 public WinColumnHeader(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(new SearchProperty(WinControl.PropertyNames.ControlType, "ColumnHeader"));
 }
Пример #16
0
 public WpfGroup(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Group");
 }
Пример #17
0
 public WinComboBox(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "ComboBox");
 }
Пример #18
0
 public WinFormsApp(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.Name, "Form1");
 }
Пример #19
0
 public WpfTitleBar(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "TitleBar");
 }
Пример #20
0
 public WpfExpander(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Expander");
 }
Пример #21
0
 public WinCheckBoxTreeItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "CheckBoxTreeItem");
 }
Пример #22
0
 public DesktopControl(DesktopContext context, string technologyName)
     : base(context, Technology.Desktop)
 {
     this._technologyName = technologyName;
 }
Пример #23
0
 public WinSeparator(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "Separator");
 }
Пример #24
0
 public WpfButton(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Button");
 }
Пример #25
0
 public WpfListItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "ListItem");
 }
Пример #26
0
 public WinToolTip(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(new SearchProperty(WinControl.PropertyNames.ControlType, "ToolTip"));
 }
Пример #27
0
 public WinPane(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "Pane");
 }
Пример #28
0
 public WpfTreeItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "TreeItem");
 }
Пример #29
0
 public WinMenuBar(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "MenuBar");
 }
Пример #30
0
 public WinRadioButton(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "RadioButton");
 }
Пример #31
0
 public WinDateTimePicker(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "DateTimePicker");
 }
Пример #32
0
 public WpfWindow(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Window");
 }
Пример #33
0
 public WinListItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "ListItem");
 }
Пример #34
0
 public WpfRadioButton(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "RadioButton");
 }
Пример #35
0
 public WinFormsApp(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.Name, "Form1");
 }
Пример #36
0
 public WinControl(DesktopContext context)
     : base(context, "MSAA")
 {
 }
Пример #37
0
 public WpfHyperlink(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Hyperlink");
 }
Пример #38
0
 public WinText(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "Text");
 }
Пример #39
0
 public WpfCheckbox(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Checkbox");
 }
Пример #40
0
 public WpfWindow(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Window");
 }
Пример #41
0
 public WpfControl(DesktopContext context)
     : base(context, "UIA")
 {
     this.SearchProperties.Add(PropertyNames.FrameworkId, "WPF");
 }
Пример #42
0
 public WpfCheckbox(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Checkbox");
 }
Пример #43
0
 public WinMenuItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "MenuItem");
 }
Пример #44
0
 public WpfToolBar(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "ToolBar");
 }
Пример #45
0
 public WinGroup(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(new SearchProperty(WinControl.PropertyNames.ControlType, "Group"));
 }
Пример #46
0
 public WpfImage(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Image");
 }
Пример #47
0
 public WinSplitButton(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(new SearchProperty(WinControl.PropertyNames.ControlType, "SplitButton"));
 }
Пример #48
0
 public WpfHyperlink(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Hyperlink");
 }
Пример #49
0
 public WpfSeparator(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Separator");
 }
Пример #50
0
 public WinDateTimePicker(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "DateTimePicker");
 }
Пример #51
0
 public WpfTabPage(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "TabPage");
 }
Пример #52
0
 public WinSlider(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "Slider");
 }
Пример #53
0
 public WpfExpander(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Expander");
 }