示例#1
0
    public async Task DispatchedEventsWillKeepBeingProcessed_ButUpdatedWillBeDelayedUntilARenderIsAcknowledged()
    {
        // Arrange
        var baseUri = new Uri(ServerFixture.RootUri, "/subdir");

        await ConnectAutomaticallyAndWait(baseUri);

        await Client.SelectAsync("test-selector-select", "BasicTestApp.LimitCounterComponent");

        Client.ConfirmRenderBatch = false;

        for (var i = 0; i < 10; i++)
        {
            await Client.ClickAsync("increment");
        }
        await Client.ClickAsync("increment", expectRenderBatch : false);

        Assert.Single(Logs, l => (LogLevel.Debug, "The queue of unacknowledged render batches is full.") == (l.LogLevel, l.Message));
        Assert.Equal("10", ((TextNode)Client.FindElementById("the-count").Children.Single()).TextContent);
        var fullCount = Batches.Count;

        // Act
        await Client.ClickAsync("increment", expectRenderBatch : false);

        Assert.Contains(Logs, l => (LogLevel.Debug, "The queue of unacknowledged render batches is full.") == (l.LogLevel, l.Message));
        Assert.Equal(fullCount, Batches.Count);
        Client.ConfirmRenderBatch = true;

        // This will resume the render batches.
        await Client.ExpectRenderBatch(() => Client.ConfirmBatch(Batches.Last().Id));

        // Assert
        Assert.Equal("12", ((TextNode)Client.FindElementById("the-count").Children.Single()).TextContent);
        Assert.Equal(fullCount + 1, Batches.Count);
    }
 public void XmlRead(XmlReader reader)
 {
     reader.ReadStartElement(nameof(BatchList));
     NextBatchId = reader.ReadElementContentAsInt(nameof(NextBatchId), "");
     while (reader.IsStartElement(nameof(Batch)))
     {
         Batches.Add(new Batch());
         Batches.Last().XmlRead(reader);
     }
 }