Example #1
0
        public void TestOptionsDictionary()
        {
            var dict = new AuthOptionsDictionary {
                Password = "******",
                Type     = AuthType.HttpBasic,
                Username = "******"
            };

            dict["type"].Should().Be("Basic");

            dict.Validate("type", "Basic").Should().BeTrue();
            dict.Validate("type", "Bogus").Should().BeFalse();
            dict.Invoking(d => d.Add("type", "Bogus"))
            .Should().Throw <InvalidOperationException>("because the type is invalid");
            dict.Invoking(d => d.Add(new KeyValuePair <string, object>("type", "Bogus")))
            .Should().Throw <InvalidOperationException>("because the type is invalid");
            dict.Invoking(d => d["type"] = "Bogus")
            .Should().Throw <InvalidOperationException>("because the type is invalid");
            dict.Invoking(d => d.Remove("type"))
            .Should().Throw <InvalidOperationException>("because the type key is required");
            dict.Invoking(d => d.Remove(new KeyValuePair <string, object>("type", "Basic")))
            .Should().Throw <InvalidOperationException>("because the type key is required");
            dict.Clear();
            dict.Count.Should().Be(0);
        }
Example #2
0
        public WebSocketTest()
#endif
        {
            var dict     = new ReplicatorOptionsDictionary();
            var authDict = new AuthOptionsDictionary();

            authDict.Username = "******";
            authDict.Password = "******";
            authDict.Type     = AuthType.HttpBasic;
            dict.Auth         = authDict;
            dict.Headers.Add("User-Agent", "CouchbaseLite/2.1.0 (.NET; Microsoft Windows 10.0.17134 ) Build/0 LiteCore/ (1261) Commit/b01fad7");
            dict.Add("WS-Protocols", "BLIP_3+CBMobile_2");
            var uri = new Uri("ws://localhost:4984");

            var s = new LiteCore.Interop.C4Socket();

            webSocketWrapper = new WebSocketWrapper(uri, (&s), dict);
        }