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 = DeserializeList(response); Assert.Contains(fileList[2], responseFileList); }
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 = DeserializeList(response); Assert.Equal(5, fileList.Count()); Assert.True(fileList.SequenceEqual(responseFileList)); }
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 = DeserializeList(response); Assert.Equal(2, fileList.Count()); Assert.True(fileList.SequenceEqual(responseFileList)); }
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 = DeserializeList(response); Assert.Equal(3, fileList.Count()); Assert.True(fileList.SequenceEqual(responseFileList)); }
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 = Deserialize(response); Assert.Equal(files[i - 1], file); } }
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 = DeserializeList(response); Assert.True(fileList.SequenceEqual(responseFileList)); response = await Client.GetAsync(requestUri + "asc"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); responseFileList = DeserializeList(response); fileList.Reverse(); Assert.True(fileList.SequenceEqual(responseFileList)); }