Ejemplo n.º 1
0
        public async Task NowFilterDateTimePropertyWithMonthFunction(string mode)
        {
            DateTimeOffset time = DateTimeOffset.Now;

            await ResetDatasource(time);

            var fileList = FilesController.CreateFiles(time);

            string requestUri = string.Format("{0}/{1}/Files?$filter=month(CreatedDate) eq month(now())", BaseAddress, mode);

            HttpResponseMessage response = await Client.GetAsync(requestUri);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var responseFileList = await DeserializeListAsync(response);

            Assert.Contains(fileList[2], responseFileList);
        }
Ejemplo n.º 2
0
        public async Task NowFilterDateTimePropertyWithDayFunction(string mode)
        {
            DateTimeOffset time     = DateTimeOffset.UtcNow;
            var            fileList = FilesController.CreateFiles(time);

            await ResetDatasource(time);

            string requestUri = string.Format("{0}/{1}/Files?$filter=day(CreatedDate) eq day(now())", BaseAddress, mode);

            HttpResponseMessage response = await Client.GetAsync(requestUri);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var responseFileList = await DeserializeListAsync(response);

            Assert.Equal(5, fileList.Count());
            Assert.True(fileList.Where(p => p.CreatedDate.Day == time.Day).OrderBy(p => p.CreatedDate).SequenceEqual(responseFileList.OrderBy(p => p.CreatedDate)));
        }
Ejemplo n.º 3
0
        public async Task NowFilterDateTimePropertyWithLt(string mode)
        {
            DateTimeOffset time     = DateTimeOffset.Now.AddHours(1);
            var            fileList = FilesController.CreateFiles(time);

            fileList = fileList.GetRange(3, 2);
            await ResetDatasource(time);

            string requestUri = string.Format("{0}/{1}/Files?$filter=CreatedDate lt now()", BaseAddress, mode);

            HttpResponseMessage response = await Client.GetAsync(requestUri);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var responseFileList = await DeserializeListAsync(response);

            Assert.Equal(2, fileList.Count());
            Assert.True(fileList.SequenceEqual(responseFileList));
        }
Ejemplo n.º 4
0
        public async Task CanFilterDateTimeProperty(string mode)
        {
            DateTimeOffset time     = new DateTimeOffset(2010, 12, 1, 12, 0, 0, TimeSpan.Zero);
            var            fileList = FilesController.CreateFiles(time);

            fileList = fileList.GetRange(2, 3);
            await ResetDatasource(time);

            string requestUri = string.Format("{0}/{1}/Files?$filter=year(CreatedDate) eq 2010", BaseAddress, mode);

            HttpResponseMessage response = await Client.GetAsync(requestUri);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var responseFileList = await DeserializeListAsync(response);

            Assert.Equal(3, fileList.Count());
            Assert.True(fileList.SequenceEqual(responseFileList));
        }
Ejemplo n.º 5
0
        public async Task QueryFileEntityTest(string mode, string mime)
        {
            DateTimeOffset serverTime = DateTimeOffset.Now;

            await ResetDatasource(serverTime);

            var files = FilesController.CreateFiles(serverTime);

            for (int i = 1; i <= 5; ++i)
            {
                string             requestUri = string.Format("{0}/{1}/Files({2})?$format={3}", BaseAddress, mode, i, mime);
                HttpRequestMessage request    = new HttpRequestMessage(HttpMethod.Get, requestUri);

                var response = await Client.SendAsync(request);

                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                File file = await DeserializeAsync(response);

                Assert.Equal(files[i - 1], file);
            }
        }
Ejemplo n.º 6
0
        public async Task CanOrderByDateTimeProperty(string mode)
        {
            DateTimeOffset time     = DateTimeOffset.Now;
            var            fileList = FilesController.CreateFiles(time);

            await ResetDatasource(time);

            string requestUri = string.Format("{0}/{1}/Files?$orderby=CreatedDate ", BaseAddress, mode);

            HttpResponseMessage response = await Client.GetAsync(requestUri + "desc");

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var responseFileList = await DeserializeListAsync(response);

            Assert.True(fileList.SequenceEqual(responseFileList));

            response = await Client.GetAsync(requestUri + "asc");

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            responseFileList = await DeserializeListAsync(response);

            fileList.Reverse();
            Assert.True(fileList.SequenceEqual(responseFileList));
        }