public async void DumpAsyncTestSuccess()
        {
            _api.SetResult(@"{result: {acknowledge: true}}");

            await _adminController.DumpAsync();

            _api.Verify(new JObject {
                { "controller", "admin" },
                { "action", "dump" }
            });
        }
Beispiel #2
0
        public async void CreateAsyncTest()
        {
            _api.SetResult(@"
        {
          result: {
            acknowledged: true,
            shards_acknowledged: true
          }
        }
      ");

            await _indexController.CreateAsync("foo");

            _api.Verify(new JObject {
                { "controller", "index" },
                { "action", "create" },
                { "index", "foo" }
            });
        }
        public async void CountAsyncTest()
        {
            string roomId = "A113";
            Int32  count  = 3;

            _api.SetResult(new JObject {
                { "result", new JObject {
                      { "count", count }
                  } }
            });

            Int32 res = await _realtimeController.CountAsync(roomId);

            _api.Verify(new JObject {
                { "controller", "realtime" },
                { "action", "count" },
                { "body", new JObject {
                      { "roomId", roomId }
                  } }
            });
            Assert.Equal <Int32>(count, res);
        }
Beispiel #4
0
        public async void ImportAsyncTestSuccess()
        {
            JObject expected = JObject.Parse(@"{items: [{create: {_id: 'documentId', status: 201}}]}");

            _api.SetResult(JObject.Parse(@"{result: {items: [{create: {_id: 'documentId', status: 201}}]}}"));

            JObject result = await _bulkController.ImportAsync(
                "foo",
                "bar",
                JArray.Parse(@"[]")
                );

            _api.Verify(new JObject {
                { "index", "foo" },
                { "collection", "bar" },
                { "controller", "bulk" },
                { "action", "import" },
                { "body", new JObject {
                      { "bulkData", JArray.Parse(@"[]") }
                  } }
            });

            Assert.Equal <JObject>(expected, result, new JTokenEqualityComparer());
        }
Beispiel #5
0
        public async void AdminExistsTest(bool returnValue)
        {
            _api.SetResult(new JObject {
                {
                    "result", new JObject {
                        { "exists", returnValue }
                    }
                }
            });

            bool res = await _serverController.AdminExistsAsync();

            _api.Verify(new JObject {
                { "controller", "server" },
                { "action", "adminExists" }
            });

            Assert.Equal(returnValue, res);
        }
        public async void CreateAsyncTest(JObject mappings)
        {
            _api.SetResult(@"{result: {acknowledge: true}}");
            await _collectionController.CreateAsync("foo", "bar", mappings);

            _api.Verify(new JObject {
                { "controller", "collection" },
                { "action", "create" },
                { "index", "foo" },
                { "collection", "bar" },
                { "body", mappings }
            });
        }
Beispiel #7
0
        public async void CountAsyncTest(JObject filters)
        {
            _api.SetResult(@"{result: {count: 42} }");
            int result = await _documentController.CountAsync("foo", "bar", filters);

            _api.Verify(new JObject {
                { "controller", "document" },
                { "action", "count" },
                { "index", "foo" },
                { "collection", "bar" },
                { "body", filters }
            });

            Assert.Equal(42, result);
        }
        public async void CheckTokenAsyncTest()
        {
            string token = "foobar";

            _api.SetResult(@"{result: {foo: 123}}");

            JObject result = await _authController.CheckTokenAsync(token);

            _api.Verify(new JObject {
                { "controller", "auth" },
                { "action", "checkToken" },
                { "body", new JObject {
                      { "token", token }
                  } }
            });

            Assert.Equal <JObject>(
                new JObject {
                { "foo", 123 }
            },
                result,
                new JTokenEqualityComparer());

            _api.Mock.VerifySet(
                a => a.AuthenticationToken = It.IsAny <string>(),
                Times.Never);
        }