Ejemplo n.º 1
0
        protected EyesBase(IServerConnectorFactory serverConnectorFactory)
        {
            ServerConnectorFactory = serverConnectorFactory;

            Logger = new Logger();

            //EnsureConfiguration_();

            ServerConnector = ServerConnectorFactory.CreateNewServerConnector(Logger);
            runningSession_ = null;
            UserInputs      = new List <Trigger>();

            properties_ = new PropertiesCollection();

            setScaleProvider_ = provider => { scaleProvider_ = provider; };
            scaleProvider_    = NullScaleProvider.Instance;
            cutProvider_      = NullCutProvider.Instance;

            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames = stackTrace.GetFrames();
            foreach (StackFrame stackFrame in stackFrames)
            {
                Type callingType = stackFrame.GetMethod().DeclaringType;
                if (callingType.IsAbstract)
                {
                    continue;
                }
                actualAssembly_ = callingType.Assembly;
                break;
            }
        }
        private SessionStartInfo GetStartInfo()
        {
            PropertiesCollection sessionProperties = new PropertiesCollection
            {
                { "property 1", "value 1" },
                { null, null }
            };

            BatchInfo batchInfo = new BatchInfo("some batch", new DateTimeOffset(new DateTime(2017, 6, 29, 11, 1, 0, DateTimeKind.Utc)));

            batchInfo.Id = "someBatchId";

            SessionStartInfo sessionStartInfo = new SessionStartInfo(
                "agent",
                "some app",
                "1.0",
                "some test",
                batchInfo,
                "baseline",
                new AppEnvironment("windows", "test suite", new Size(234, 456))
            {
                DeviceInfo = "Some Mobile Device"
            },
                "some environment",
                new ImageMatchSettings(MatchLevel.Strict),
                "some branch",
                "parent branch",
                "baseline branch",
                saveDiffs: null,
                render: null,
                properties: sessionProperties);

            return(sessionStartInfo);
        }
Ejemplo n.º 3
0
        public void TestSerialization()
        {
            PropertiesCollection sessionProperties = new PropertiesCollection
            {
                { "property 1", "value 1" },
                { null, null }
            };

            string agentRunId = "some-agent-run-id";

            BatchInfo batchInfo = new BatchInfo("some batch", new DateTimeOffset(new DateTime(2017, 6, 29, 11, 1, 0, DateTimeKind.Utc)));

            batchInfo.Id = "someBatchId";
            batchInfo.Properties.Add("prop 1", "val 1");
            batchInfo.AddProperty("prop 2", null);

            SessionStartInfo sessionStartInfo = new SessionStartInfo(
                "agent",
                "some app",
                "1.0",
                "some test",
                batchInfo,
                "baseline",
                new AppEnvironment("windows", "test suite", new RectangleSize(234, 456))
            {
                DeviceInfo = "Some Mobile Device"
            },
                "some environment",
                new ImageMatchSettings(MatchLevel.Strict)
            {
                Accessibility         = new AccessibilityRegionByRectangle[] { new AccessibilityRegionByRectangle(10, 20, 30, 40, AccessibilityRegionType.GraphicalObject) },
                AccessibilitySettings = new AccessibilitySettings(AccessibilityLevel.AA, AccessibilityGuidelinesVersion.WCAG_2_1),
                Floating = new FloatingMatchSettings[] { new FloatingMatchSettings(22, 32, 42, 52, 5, 10, 15, 20) }
            },
                "some branch",
                "parent branch",
                "baseline branch",
                saveDiffs: null,
                render: null,
                agentSessionId: "59436361-2782-45EF-9DC5-5633F15150CE",
                timeout: 10,
                properties: sessionProperties,
                agentRunId);

            string json         = JsonConvert.SerializeObject(sessionStartInfo, Formatting.Indented);
            string expectedJson = CommonUtils.ReadResourceFile("Test.Eyes.Sdk.Core.DotNet.Resources.SessionStartInfo_Serialization.json");

            Assert.AreEqual(expectedJson, json);
        }
Ejemplo n.º 4
0
        public void TestDeserialization()
        {
            string    json      = "{\"id\": \"abc-def\",\"name\": \"SomeName\",\"isImplicit\": false,\"startedAt\": \"2021-03-18T15:37:00Z\",\"lastRunAt\": \"2021-03-18T15:37:04.8603032Z\",\"duration\": 0,\"notifyOnCompletion\": false,\"properties\": [{\"name\": \"some\", \"value\":\"thing\"}]}";
            BatchInfo batchInfo = JsonConvert.DeserializeObject <BatchInfo>(json);

            Assert.AreEqual("abc-def", batchInfo.Id);
            Assert.AreEqual("SomeName", batchInfo.Name);
            Assert.AreEqual(new DateTimeOffset(2021, 3, 18, 15, 37, 0, TimeSpan.Zero), batchInfo.StartedAt);
            Assert.AreEqual(false, batchInfo.NotifyOnCompletion);

            PropertiesCollection props = new PropertiesCollection();

            props.Add("some", "thing");
            CollectionAssert.AreEquivalent(props, batchInfo.Properties);
        }
Ejemplo n.º 5
0
        public SessionStartInfo(
            string agentId,
            string appName,
            string verId,
            string testName,
            BatchInfo batchInfo,
            string baselineEnvName,
            object environment,
            string envName,
            ImageMatchSettings defaultMatchSettings,
            string branchName,
            string parentBranchName,
            string baselineBranchName,
            bool?saveDiffs,
            bool?render,
            string agentSessionId,
            int?timeout,
            PropertiesCollection properties,
            string agentRunId)
        {
            ArgumentGuard.NotEmpty(agentId, nameof(agentId));
            ArgumentGuard.NotEmpty(appName, nameof(appName));
            ArgumentGuard.NotEmpty(testName, nameof(testName));
            ArgumentGuard.NotNull(batchInfo, nameof(batchInfo));
            ArgumentGuard.NotNull(environment, nameof(environment));
            ArgumentGuard.NotNull(defaultMatchSettings, nameof(defaultMatchSettings));

            AgentId              = agentId;
            AppIdOrName          = appName;
            VerId                = verId;
            ScenarioIdOrName     = testName;
            BatchInfo            = batchInfo;
            BaselineEnvName      = baselineEnvName;
            Environment          = environment;
            EnvironmentName      = envName;
            DefaultMatchSettings = defaultMatchSettings;
            BranchName           = branchName;
            ParentBranchName     = parentBranchName;
            BaselineBranchName   = baselineBranchName;
            SaveDiffs            = saveDiffs;
            Render               = render;
            AgentSessionId       = agentSessionId;
            Timeout              = timeout;
            Properties           = properties;
            AgentRunId           = agentRunId;
        }
Ejemplo n.º 6
0
        private void Init_(ClassicRunner runner, Logger logger)
        {
            runner_ = runner ?? new ClassicRunner();
            Logger  = logger ?? new Logger();

            runner_.SetEyes(this);

            //EnsureConfiguration_();

            UpdateActualAssembly_();
            runningSession_ = null;
            UserInputs      = new List <Trigger>();
            properties_     = new PropertiesCollection();

            setScaleProvider_ = provider => { scaleProvider_ = provider; };
            scaleProvider_    = NullScaleProvider.Instance;
            cutProvider_      = NullCutProvider.Instance;
        }