public async Task ODataOrderingNonExistingPropertiesThrows() { await Prepared.ConfigureAwait(false); 0.Awaiting(async _ => await QueryInstallations("select=Name,TotallyNotAProperty").ConfigureAwait(false)) .Should().Throw <ODataException>(); }
public async Task ODataNameOfInstallation() { await Prepared.ConfigureAwait(false); var lst = await QueryInstallations("select=Name,Id").ConfigureAwait(false); lst.Should().BeEquivalentTo(TestSource.Installations, cfg => cfg.ExcludingMissingMembers()); }
public async Task ObservingThoughApiWorks() { await Prepared.ConfigureAwait(false); var builder = new HubConnectionBuilder() .WithUrl($"http://test{LiveHub.Route}", cfg => cfg.HttpMessageHandlerFactory = _ => Server.CreateHandler()) ; var hubConnection = builder.Build(); await hubConnection.StartAsync(); var obs = hubConnection.Observe <ChangeData>(nameof(LiveHub.Observe)); const int takeCount = 10; var sem = new SemaphoreSlim(2); // Coordinate progress between produced data and listener var obsTask = obs .TraceTest(Output) .Take(takeCount) .Select((v, idx) => new { v, idx }) // Start a new producer whenever we have received 5 items .Do(x => { if (x.idx % 5 == 0) { sem.Release(); } }) .TraceTest(Output) .Select(x => x.v) .ToListAsync(CancellationToken); var pushTask = TestSource.ProduceData( // Wait for sem for each batch of data sem.ObserveRelease().Take(2).Select(_ => DateTime.UtcNow) .TraceTest(Output) ) .TraceTest(Output) .SelectMany(x => x) .TraceTest(Output) .ToListAsync(CancellationToken); // All ready, start pusing sem.Release(); var observedChanges = await obsTask.ConfigureAwait(false); var observed = observedChanges.Select(c => c.Entity).ToList(); var pushed = await pushTask.ConfigureAwait(false); var expect = pushed.Take(takeCount); observed.Should().BeEquivalentTo(expect, cfg => cfg.Excluding(x => x.Installation).Excluding(x => x.Signal)); // Reception should contained interleaved data observed.Select(x => x.InstallationId) .Should().NotBeAscendingInOrder() .And.NotBeDescendingInOrder(); }
protected async Task <IList <Installation> > QueryInstallations(string args) { await Prepared.ConfigureAwait(false); return(await Client.GetJsonAsync <List <Installation> >( new Uri(Server.BaseAddress, $"/odata/Installation?${args}"), JsonSerializer, CancellationToken ).ConfigureAwait(false)); }
public async Task GetTurbinesByIdReturnsExpectedParquet() { await Prepared.ConfigureAwait(false); var server = Server; var got = await SendAsyncParquet <Installation>( new Uri(server.BaseAddress, $"{InstallationXController.RoutePrefix}/{InstallationXController.AllRoute}") .GetRequest()) .ConfigureAwait(false); got.Should().BeEquivalentTo(TestSource.Installations, cfg => cfg.ExcludingMissingMembers() // Currently Guid is not serialized :( .Excluding(x => x.Id)); }
public async Task GetTurbinesByIdReturnsExpectedJson(int index) { await Prepared.ConfigureAwait(false); var client = await Client.ConfigureAwait(false); var i = TestSource.Installations.Skip(index).First(); var got = await client.GetJsonAsync <Installation>( new Uri(Server.BaseAddress, $"{InstallationXController.RoutePrefix}/{i.Id}"), JsonSerializer, CancellationToken ); var expected = new Installation(i.Id, i.Name, i.InstallationPeriod.From, i.InstallationPeriod.To); got.Should().BeEquivalentTo(expected); }