Exemplo n.º 1
0
 public void SelectLocalTest([DataSources] string context)
 {
     using (var db = GetDataContext(context))
     {
         var c = new LocalClass();
         var _ = db.Parent.Select(p => new { c, p.Value1 }).Distinct().ToList();
     }
 }
    static void Main(string[] args)
    {
        InitializeRemoting();
        var remote = GetRemotingObject("localhost");
        var local  = new LocalClass();

        remote.SomeMethod();
        local.SomeMethod();
        Console.ReadLine();
    }
Exemplo n.º 3
0
        public void TestWorksWithAccessKeyInOptions()
        {
            options = new List <KeyValuePair <string, string> >();
            options.Add(new KeyValuePair <string, string>("key", "dummyKey"));
            local = new LocalClass();
            Mock <BrowserStackTunnel> tunnelMock = new Mock <BrowserStackTunnel>();

            local.setTunnel(tunnelMock.Object);
            Assert.DoesNotThrow(new TestDelegate(startWithOptions),
                                "BROWSERSTACK_ACCESS_KEY cannot be empty. Specify one by adding key to options or adding to the environment variable BROWSERSTACK_ACCESS_KEY.");
            tunnelMock.Verify(mock => mock.addBinaryArguments("-logFile \"" + logAbsolute + "\" "), Times.Once());
            tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
            local.stop();
        }
Exemplo n.º 4
0
        public void TestWorksForFolderTesting()
        {
            options = new List <KeyValuePair <string, string> >();
            options.Add(new KeyValuePair <string, string>("key", "dummyKey"));
            options.Add(new KeyValuePair <string, string>("f", "dummyFolderPath"));

            local = new LocalClass();
            Mock <BrowserStackTunnel> tunnelMock = new Mock <BrowserStackTunnel>();

            tunnelMock.Setup(mock => mock.Run("dummyKey", "dummyFolderPath", logAbsolute, "start"));
            local.setTunnel(tunnelMock.Object);
            local.start(options);
            tunnelMock.Verify(mock => mock.addBinaryArguments("-logFile \"" + logAbsolute + "\" "), Times.Once());
            tunnelMock.Verify(mock => mock.Run("dummyKey", "dummyFolderPath", logAbsolute, "start"), Times.Once());
            local.stop();
        }
Exemplo n.º 5
0
        public void TestThrowsWithNoAccessKey()
        {
            options = new List <KeyValuePair <string, string> >();
            options.Add(new KeyValuePair <string, string>("key", ""));
            local = new LocalClass();

            Mock <BrowserStackTunnel> tunnelMock = new Mock <BrowserStackTunnel>();

            tunnelMock.Setup(mock => mock.Run("", "", logAbsolute, "start"));
            local.setTunnel(tunnelMock.Object);

            Assert.Throws(typeof(Exception),
                          new TestDelegate(startWithOptions),
                          "BROWSERSTACK_ACCESS_KEY cannot be empty. Specify one by adding key to options or adding to the environment variable BROWSERSTACK_ACCESS_KEY.");
            local.stop();
        }
Exemplo n.º 6
0
        public void Should_prevent_local_evaluation_of_annotated_method()
        {
            var i   = new LocalClass();
            var m   = typeof(LocalClass).GetMethod(nameof(LocalClass.QueryFunction));
            var exp = SystemLinq.Expression.Call(SystemLinq.Expression.Constant(i), m);

            var rlinq = exp.ToRemoteLinqExpression();

            var call = rlinq.ShouldBeOfType <RemoteLinq.MethodCallExpression>();

            call.Arguments.ShouldBeEmpty();
            call.Method.ToMethodInfo().ShouldBe(m);
            call.Instance.ShouldBeOfType <RemoteLinq.ConstantExpression>()
            .Value.ShouldBeOfType <ConstantQueryArgument>()
            .Value.ShouldBeOfType <DynamicObject>()
            .Type.ToType().ShouldBe(typeof(LocalClass));
        }
Exemplo n.º 7
0
        public void TestWorksWithBooleanOptions()
        {
            options = new List <KeyValuePair <string, string> >();
            options.Add(new KeyValuePair <string, string>("key", "dummyKey"));
            options.Add(new KeyValuePair <string, string>("v", "true"));
            options.Add(new KeyValuePair <string, string>("force", "true"));
            options.Add(new KeyValuePair <string, string>("forcelocal", "true"));
            options.Add(new KeyValuePair <string, string>("forceproxy", "true"));
            options.Add(new KeyValuePair <string, string>("onlyAutomate", "true"));

            local = new LocalClass();
            Mock <BrowserStackTunnel> tunnelMock = new Mock <BrowserStackTunnel>();

            tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
            local.setTunnel(tunnelMock.Object);
            local.start(options);
            tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
            tunnelMock.Verify(mock => mock.addBinaryArguments(It.IsRegex("-vvv.*-force.*-forcelocal.*-forceproxy.*-onlyAutomate")), Times.Once());
            tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
            local.stop();
        }
Exemplo n.º 8
0
        public void TestWorksWithCustomOptions()
        {
            options = new List <KeyValuePair <string, string> >();
            options.Add(new KeyValuePair <string, string>("key", "dummyKey"));
            options.Add(new KeyValuePair <string, string>("customBoolKey1", "true"));
            options.Add(new KeyValuePair <string, string>("customBoolKey2", "false"));
            options.Add(new KeyValuePair <string, string>("customKey1", "customValue1"));
            options.Add(new KeyValuePair <string, string>("customKey2", "customValue2"));

            local = new LocalClass();
            Mock <BrowserStackTunnel> tunnelMock = new Mock <BrowserStackTunnel>();

            tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
            local.setTunnel(tunnelMock.Object);
            local.start(options);
            tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
            tunnelMock.Verify(mock => mock.addBinaryArguments(
                                  It.IsRegex("-customBoolKey1.*-customBoolKey2.*-customKey1.*customValue1.*-customKey2.*customValue2")
                                  ), Times.Once());
            tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
            local.stop();
        }
        public void TestCallsFallbackOnFailure()
        {
            options = new List<KeyValuePair<string, string>>();
              options.Add(new KeyValuePair<string, string>("key", "dummyKey"));

              local = new LocalClass();
              int count = 0;
              Mock<BrowserStackTunnel> tunnelMock = new Mock<BrowserStackTunnel>();
              tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start")).Callback(() =>
              {
            count++;
            if (count == 1)
              throw new ApplicationException();
              });
              local.setTunnel(tunnelMock.Object);
              local.start(options);
              tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
              tunnelMock.Verify(mock => mock.addBinaryArguments("-logFile \"" + logAbsolute + "\" "), Times.Once());
              tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Exactly(2));
              tunnelMock.Verify(mock => mock.fallbackPaths(), Times.Once());
              local.stop();
        }
Exemplo n.º 10
0
        public void TestWorksWithValueOptions()
        {
            options = new List <KeyValuePair <string, string> >();
            options.Add(new KeyValuePair <string, string>("key", "dummyKey"));
            options.Add(new KeyValuePair <string, string>("localIdentifier", "dummyIdentifier"));
            options.Add(new KeyValuePair <string, string>("hosts", "dummyHost"));
            options.Add(new KeyValuePair <string, string>("proxyHost", "dummyHost"));
            options.Add(new KeyValuePair <string, string>("proxyPort", "dummyPort"));
            options.Add(new KeyValuePair <string, string>("proxyUser", "dummyUser"));
            options.Add(new KeyValuePair <string, string>("proxyPass", "dummyPass"));

            local = new LocalClass();
            Mock <BrowserStackTunnel> tunnelMock = new Mock <BrowserStackTunnel>();

            tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
            local.setTunnel(tunnelMock.Object);
            local.start(options);
            tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
            tunnelMock.Verify(mock => mock.addBinaryArguments(
                                  It.IsRegex("-localIdentifier.*dummyIdentifier.*dummyHost.*-proxyHost.*dummyHost.*-proxyPort.*dummyPort.*-proxyUser.*dummyUser.*-proxyPass.*dummyPass")
                                  ), Times.Once());
            tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
            local.stop();
        }
        public void TestKillsTunnel()
        {
            options = new List<KeyValuePair<string, string>>();
              options.Add(new KeyValuePair<string, string>("key", "dummyKey"));

              local = new LocalClass();
              Mock<BrowserStackTunnel> tunnelMock = new Mock<BrowserStackTunnel>();
              tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
              local.setTunnel(tunnelMock.Object);
              local.start(options);
              local.stop();
              tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
              tunnelMock.Verify(mock => mock.addBinaryArguments("-logFile \"" + logAbsolute + "\" "), Times.Once());
              tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
        }
        public void TestWorksWithValueOptions()
        {
            options = new List<KeyValuePair<string, string>>();
              options.Add(new KeyValuePair<string, string>("key", "dummyKey"));
              options.Add(new KeyValuePair<string, string>("localIdentifier", "dummyIdentifier"));
              options.Add(new KeyValuePair<string, string>("hosts", "dummyHost"));
              options.Add(new KeyValuePair<string, string>("proxyHost", "dummyHost"));
              options.Add(new KeyValuePair<string, string>("proxyPort", "dummyPort"));
              options.Add(new KeyValuePair<string, string>("proxyUser", "dummyUser"));
              options.Add(new KeyValuePair<string, string>("proxyPass", "dummyPass"));

              local = new LocalClass();
              Mock<BrowserStackTunnel> tunnelMock = new Mock<BrowserStackTunnel>();
              tunnelMock.Setup(mock =>mock.Run("dummyKey", "", logAbsolute, "start"));
              local.setTunnel(tunnelMock.Object);
              local.start(options);
              tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
              tunnelMock.Verify(mock => mock.addBinaryArguments(
            It.IsRegex("-localIdentifier.*dummyIdentifier.*dummyHost.*-proxyHost.*dummyHost.*-proxyPort.*dummyPort.*-proxyUser.*dummyUser.*-proxyPass.*dummyPass")
            ), Times.Once());
              tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
              local.stop();
        }
        public void TestWorksWithCustomOptions()
        {
            options = new List<KeyValuePair<string, string>>();
              options.Add(new KeyValuePair<string, string>("key", "dummyKey"));
              options.Add(new KeyValuePair<string, string>("customBoolKey1", "true"));
              options.Add(new KeyValuePair<string, string>("customBoolKey2", "false"));
              options.Add(new KeyValuePair<string, string>("customKey1", "customValue1"));
              options.Add(new KeyValuePair<string, string>("customKey2", "customValue2"));

              local = new LocalClass();
              Mock<BrowserStackTunnel> tunnelMock = new Mock<BrowserStackTunnel>();
              tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
              local.setTunnel(tunnelMock.Object);
              local.start(options);
              tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
              tunnelMock.Verify(mock => mock.addBinaryArguments(
            It.IsRegex("-customBoolKey1.*-customBoolKey2.*-customKey1.*customValue1.*-customKey2.*customValue2")
            ), Times.Once());
              tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
              local.stop();
        }
        public void TestWorksWithBooleanOptions()
        {
            options = new List<KeyValuePair<string, string>>();
              options.Add(new KeyValuePair<string, string>("key", "dummyKey"));
              options.Add(new KeyValuePair<string, string>("v", "true"));
              options.Add(new KeyValuePair<string, string>("force", "true"));
              options.Add(new KeyValuePair<string, string>("forcelocal", "true"));
              options.Add(new KeyValuePair<string, string>("forceproxy", "true"));
              options.Add(new KeyValuePair<string, string>("onlyAutomate", "true"));

              local = new LocalClass();
              Mock<BrowserStackTunnel> tunnelMock = new Mock<BrowserStackTunnel>();
              tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute, "start"));
              local.setTunnel(tunnelMock.Object);
              local.start(options);
              tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
              tunnelMock.Verify(mock => mock.addBinaryArguments(It.IsRegex("-vvv.*-force.*-forcelocal.*-forceproxy.*-onlyAutomate")), Times.Once());
              tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute, "start"), Times.Once());
              local.stop();
        }
 public void TestWorksWithAccessKeyNotInOptions()
 {
     Environment.SetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY", "envDummyKey");
       options = new List<KeyValuePair<string, string>>();
       local = new LocalClass();
       Mock<BrowserStackTunnel> tunnelMock = new Mock<BrowserStackTunnel>();
       tunnelMock.Setup(mock => mock.Run("envDummyKey", "", logAbsolute, "start"));
       local.setTunnel(tunnelMock.Object);
       Assert.DoesNotThrow(new TestDelegate(startWithOptions),
     "BROWSERSTACK_ACCESS_KEY cannot be empty. Specify one by adding key to options or adding to the environment variable BROWSERSTACK_ACCESS_KEY.");
       tunnelMock.Verify(mock => mock.addBinaryArguments("-logFile \"" + logAbsolute + "\" "), Times.Once());
       tunnelMock.Verify(mock => mock.Run("envDummyKey", "", logAbsolute, "start"), Times.Once());
       local.stop();
 }
        public void TestThrowsWithNoAccessKey()
        {
            options = new List<KeyValuePair<string, string>>();
              options.Add(new KeyValuePair<string, string>("key", ""));
              local = new LocalClass();

              Mock<BrowserStackTunnel> tunnelMock = new Mock<BrowserStackTunnel>();
              tunnelMock.Setup(mock => mock.Run("", "", logAbsolute, "start"));
              local.setTunnel(tunnelMock.Object);

              Assert.Throws(typeof(Exception),
            new TestDelegate(startWithOptions),
            "BROWSERSTACK_ACCESS_KEY cannot be empty. Specify one by adding key to options or adding to the environment variable BROWSERSTACK_ACCESS_KEY.");
              local.stop();
        }