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());
        }
Example #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");
        }
Example #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());
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #10
0
 public WinTabList(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "TabList");
 }
Example #11
0
 public WinProgressBar(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "ProgressBar");
 }
Example #12
0
 public WinRowHeader(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "RowHeader");
 }
Example #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));
            }
        }
Example #14
0
 public WpfGroup(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Group");
 }
Example #15
0
 public WinColumnHeader(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(new SearchProperty(WinControl.PropertyNames.ControlType, "ColumnHeader"));
 }
Example #16
0
 public WpfGroup(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Group");
 }
Example #17
0
 public WinComboBox(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "ComboBox");
 }
Example #18
0
 public WinFormsApp(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.Name, "Form1");
 }
Example #19
0
 public WpfTitleBar(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "TitleBar");
 }
Example #20
0
 public WpfExpander(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Expander");
 }
Example #21
0
 public WinCheckBoxTreeItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "CheckBoxTreeItem");
 }
Example #22
0
 public DesktopControl(DesktopContext context, string technologyName)
     : base(context, Technology.Desktop)
 {
     this._technologyName = technologyName;
 }
Example #23
0
 public WinSeparator(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "Separator");
 }
Example #24
0
 public WpfButton(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Button");
 }
Example #25
0
 public WpfListItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "ListItem");
 }
Example #26
0
 public WinToolTip(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(new SearchProperty(WinControl.PropertyNames.ControlType, "ToolTip"));
 }
Example #27
0
 public WinPane(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "Pane");
 }
Example #28
0
 public WpfTreeItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "TreeItem");
 }
Example #29
0
 public WinMenuBar(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "MenuBar");
 }
Example #30
0
 public WinRadioButton(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "RadioButton");
 }
Example #31
0
 public WinDateTimePicker(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "DateTimePicker");
 }
Example #32
0
 public WpfWindow(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Window");
 }
Example #33
0
 public WinListItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "ListItem");
 }
Example #34
0
 public WpfRadioButton(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "RadioButton");
 }
Example #35
0
 public WinFormsApp(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.Name, "Form1");
 }
Example #36
0
 public WinControl(DesktopContext context)
     : base(context, "MSAA")
 {
 }
Example #37
0
 public WpfHyperlink(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Hyperlink");
 }
Example #38
0
 public WinText(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "Text");
 }
Example #39
0
 public WpfCheckbox(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Checkbox");
 }
Example #40
0
 public WpfWindow(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Window");
 }
Example #41
0
 public WpfControl(DesktopContext context)
     : base(context, "UIA")
 {
     this.SearchProperties.Add(PropertyNames.FrameworkId, "WPF");
 }
Example #42
0
 public WpfCheckbox(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Checkbox");
 }
Example #43
0
 public WinMenuItem(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "MenuItem");
 }
Example #44
0
 public WpfToolBar(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "ToolBar");
 }
Example #45
0
 public WinGroup(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(new SearchProperty(WinControl.PropertyNames.ControlType, "Group"));
 }
Example #46
0
 public WpfImage(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Image");
 }
Example #47
0
 public WinSplitButton(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(new SearchProperty(WinControl.PropertyNames.ControlType, "SplitButton"));
 }
Example #48
0
 public WpfHyperlink(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Hyperlink");
 }
Example #49
0
 public WpfSeparator(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Separator");
 }
Example #50
0
 public WinDateTimePicker(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "DateTimePicker");
 }
Example #51
0
 public WpfTabPage(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "TabPage");
 }
Example #52
0
 public WinSlider(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WinControl.PropertyNames.ControlType, "Slider");
 }
Example #53
0
 public WpfExpander(DesktopContext context)
     : base(context)
 {
     this.SearchProperties.Add(WpfControl.PropertyNames.ControlType, "Expander");
 }