Exemplo n.º 1
0
        public async Task <StatementsResultLrsResponse> QueryStatementsAsync(StatementsQuery query)
        {
            var r = new StatementsResultLrsResponse();

            var req = new MyHttpRequest
            {
                Method      = "GET",
                Resource    = "statements",
                QueryParams = query.ToParameterMap(Version)
            };

            var res = await MakeRequest(req);

            if (res.Status != HttpStatusCode.OK)
            {
                r.Success       = false;
                r.HttpException = res.Ex;
                r.SetErrMsgFromBytes(res.Content);
                return(r);
            }

            r.Success = true;
            r.Content = new StatementsResult(new Json.StringOfJson(Encoding.UTF8.GetString(res.Content)));

            return(r);
        }
Exemplo n.º 2
0
        public async Task <StatementsResultLRSResponse> QueryStatements(StatementsQuery query)
        {
            var r = new StatementsResultLRSResponse();

            var req = new MyHTTPRequest();

            req.method      = HttpMethod.Get;
            req.resource    = "statements";
            req.queryParams = query.ToParameterMap(version);

            var res = await MakeRequest(req);

            if (res.status != HttpStatusCode.OK)
            {
                r.success       = false;
                r.httpException = res.ex;
                r.SetErrMsgFromBytes(res.content, (int)res.status);
                return(r);
            }

            r.success = true;
            r.content = new StatementsResult(new Json.StringOfJSON(Encoding.UTF8.GetString(res.content, 0, res.content.Length)));

            return(r);
        }
        public async Task TestQueryStatements()
        {
            var query = new TinCan.StatementsQuery();

            query.agent             = Support.agent;
            query.verbId            = Support.verb.id;
            query.activityId        = Support.parent.id;
            query.relatedActivities = true;
            query.relatedAgents     = true;
            query.format            = StatementsQueryResultFormat.IDS;
            query.limit             = 10;

            StatementsResultLRSResponse lrsRes = await lrs.QueryStatements(query);

            Assert.True(lrsRes.success);
            Console.WriteLine("TestQueryStatements - statement count: " + lrsRes.content.statements.Count);
        }
Exemplo n.º 4
0
        public void TestMoreStatements()
        {
            var query = new TinCan.StatementsQuery();

            query.format = StatementsQueryResultFormat.IDS;
            query.limit  = 2;

            StatementsResultLRSResponse queryRes = lrs.QueryStatements(query);

            if (queryRes.success && queryRes.content.more != null)
            {
                StatementsResultLRSResponse moreRes = lrs.MoreStatements(queryRes.content);
                Assert.IsTrue(moreRes.success);
                Console.WriteLine("TestMoreStatements - statement count: " + moreRes.content.statements.Count);
            }
            else
            {
                // TODO: skipped?
            }
        }
Exemplo n.º 5
0
        public StatementsResultLRSResponse QueryStatements(StatementsQuery query)
        {
            var r = new StatementsResultLRSResponse();

            var req = new MyHTTPRequest();
            req.method = "GET";
            req.resource = "statements";
            req.queryParams = query.ToParameterMap(version);

            var res = MakeSyncRequest(req);
            if (res.status != HttpStatusCode.OK)
            {
                r.success = false;
                r.httpException = res.ex;
                r.SetErrMsgFromBytes(res.content);
                return r;
            }

            r.success = true;
            r.content = new StatementsResult(new Json.StringOfJSON(Encoding.UTF8.GetString(res.content)));

            return r;
        }
        public void TestMoreStatements()
        {
            var query = new TinCan.StatementsQuery();
            query.format = StatementsQueryResultFormat.IDS;
            query.limit = 2;

            StatementsResultLRSResponse queryRes = lrs.QueryStatements(query);
            if (queryRes.success && queryRes.content.more != null)
            {
                StatementsResultLRSResponse moreRes = lrs.MoreStatements(queryRes.content);
                Assert.IsTrue(moreRes.success);
                Console.WriteLine("TestMoreStatements - statement count: " + moreRes.content.statements.Count);
            }
            else
            {
                // TODO: skipped?
            }
        }
        public void TestQueryStatements()
        {
            var query = new TinCan.StatementsQuery();
            query.agent = agent;
            query.verbId = verb.id;
            query.activityId = parent.id;
            query.relatedActivities = true;
            query.relatedAgents = true;
            query.format = StatementsQueryResultFormat.IDS;
            query.limit = 10;

            StatementsResultLRSResponse lrsRes = lrs.QueryStatements(query);
            Assert.IsTrue(lrsRes.success);
            Console.WriteLine("TestQueryStatements - statement count: " + lrsRes.content.statements.Count);
        }