public void Query_TaskAsync_Single_WithException_InTask() { var ctx = new ServerSideAsyncDomainContext(TestURIs.ServerSideAsync); var exceptionFirstQuery = ctx.GetRangeByIdWithExceptionTaskQuery(2); const int expectedErrorCode = 24; const string expectedMessage = "GetRangeByIdWithExceptionTask"; var load = ctx.LoadAsync(exceptionFirstQuery); this.EnqueueConditional(() => load.IsCompleted); this.EnqueueCallback(() => { Assert.IsNotNull(load.Exception, "Exception is null"); var dex = ((DomainException)load.Exception.InnerException); Assert.AreEqual(expectedErrorCode, dex.ErrorCode, "Wrong error code"); Assert.AreEqual(expectedMessage, dex.Message, "Wrong error message"); }); this.EnqueueTestComplete(); }
public void Query_TaskAsync_Single() { var ctx = new ServerSideAsyncDomainContext(TestURIs.ServerSideAsync); const int expectedId = 4; var query = ctx.GetRangeByIdQuery(expectedId); var load = ctx.LoadAsync(query); this.EnqueueConditional(() => load.IsCompleted); this.EnqueueCallback(() => { Assert.IsNull(load.Exception, "Load failed"); Assert.AreEqual(1, load.Result.Count, "Only 1 entity should have been loaded"); Assert.AreEqual(expectedId, load.Result.First().Id); }); this.EnqueueTestComplete(); }
public void Query_TaskAsync_WithFilter() { var ctx = new ServerSideAsyncDomainContext(TestURIs.ServerSideAsync); const int expectedId = 3; Expression<Func<RangeItem, bool>> filter = (RangeItem item) => item.Id == expectedId; var normalQuery = ctx.GetRangeQuery().Where(filter); var asyncQuery = ctx.GetQueryableRangeQuery().Where(filter); normalQuery.IncludeTotalCount = true; asyncQuery.IncludeTotalCount = true; var normalLoadTask = ctx.LoadAsync(normalQuery); var asyncLoadTask = ctx.LoadAsync(asyncQuery); this.EnqueueConditional(() => normalLoadTask.IsCompleted); this.EnqueueConditional(() => asyncLoadTask.IsCompleted); this.EnqueueCallback(() => { Assert.IsNull(normalLoadTask.Exception, "Normal load failed"); Assert.IsNull(asyncLoadTask.Exception, "Async load failed"); var normalLoad = normalLoadTask.Result; var asyncLoad = asyncLoadTask.Result; CollectionAssert.AreEquivalent(normalLoad, asyncLoad); Assert.AreEqual(1, normalLoad.Count, "Only 1 entity should have been loaded"); Assert.AreEqual(expectedId, asyncLoad.Entities.First().Id); // Check Total entity count Assert.AreEqual(normalLoad.TotalEntityCount, asyncLoad.TotalEntityCount, "TotalEntityCount different"); Assert.AreEqual(1, normalLoad.TotalEntityCount, "Wrong TotalEntityCount"); }); this.EnqueueTestComplete(); }
public void Query_TaskAsync() { var ctx = new ServerSideAsyncDomainContext(TestURIs.ServerSideAsync); var normalQuery = ctx.GetRangeQuery(); var asyncQuery = ctx.GetQueryableRangeQuery(); var normalLoad = ctx.Load(normalQuery); var asyncLoad = ctx.LoadAsync(asyncQuery); this.EnqueueConditional(() => normalLoad.IsComplete); this.EnqueueConditional(() => asyncLoad.IsCompleted); this.EnqueueCallback(() => { Assert.IsNull(normalLoad.Error, "Normal load failed"); Assert.IsNull(asyncLoad.Exception, "Async load failed"); CollectionAssert.AreEquivalent(normalLoad.Entities.ToArray(), asyncLoad.Result); Assert.IsTrue(normalLoad.Entities.Any(), "No entities loaded"); Assert.AreEqual(normalLoad.TotalEntityCount, asyncLoad.Result.TotalEntityCount, "TotalEntityCount different"); }); this.EnqueueTestComplete(); }