Exemple #1
0
        public async Task AnonymousTypeInSubQueryArray()
        {
            var service = TestService.Create(TestService.UnrestrictedOptions, new[] { typeof(EnumerableEx) }, Observable.Return(123));

            var results = await service.QueryAsync(source =>
                                                   from _ in source
                                                   select new[] { new { Value = "test" } }.First());

            QactiveAssert.AreEqual(results,
                                   OnNext(new { Value = "test" }),
                                   OnCompleted(new { Value = default(string) }));
        }
 public Task <IReadOnlyCollection <Notification <TResult> > > QueryAsync <TResult>(
     Func <IQbservable <TSource>, IQbservable <TResult> > query,
     IEnumerable <Exception> expectedClientTerminationErrors = null,
     Exception expectedServerError = null,
     TimeSpan?timeout = null)
 => RunQueryAsync(Observable.Merge(
                      ServeQbservable(source).Take(1)
                      .Do(termination => QactiveAssert.AreEqual(termination.Exceptions.Select(ex => ex.SourceException), expectedClientTerminationErrors),
                          ex => QactiveAssert.AreEqual(ex, expectedServerError, "Unexpected server error: " + ex.ToString()),
                          () => Assert.IsNull(expectedServerError, "A server error was expected, but the sequence completed instead."))
                      .IgnoreElements()
                      .Cast <TResult>(),
                      // Defer is required to ensure that the server is subscribed to first so that in case the port is 0, the TCP listener is started before the client query is
                      // created, thus the the port selected by TCP will be known at this point in time and can be passed to the TcpQbservableClient. See TcpTestService<TSource>.
                      Observable.Defer(() => query(CreateQuery()).AsObservable()))
                  .Timeout(Debugger.IsAttached ? TimeSpan.FromDays(5) : timeout ?? TimeSpan.FromSeconds(5)));