Beispiel #1
0
    public void ForEachSegment_Does_Not_Invokes_Handler_For_Empty_Data()
    {
        var data    = new ReadOnlySequence <byte>();
        var handler = A.Fake <Action <ReadOnlyMemory <byte> > >();

        data.ForEachSegment(handler);

        A.CallTo(() => handler.Invoke(A <ReadOnlyMemory <byte> > ._)).MustNotHaveHappened();
    }
Beispiel #2
0
    public async Task ForEachSegment_Does_Not_Invokes_Async_Handler_For_Empty_Data()
    {
        var data    = new ReadOnlySequence <byte>();
        var handler = A.Fake <Func <ReadOnlyMemory <byte>, CancellationToken, Task> >();

        await data.ForEachSegment(handler);

        A.CallTo(() => handler.Invoke(A <ReadOnlyMemory <byte> > ._, A <CancellationToken> ._)).MustNotHaveHappened();
    }
Beispiel #3
0
    public void ForEachSegment_Invokes_Handler_For_Single_Segment()
    {
        var segment = Guid.NewGuid().ToByteArray().AsMemory();
        var data    = new ReadOnlySequence <byte>(segment);
        var handler = A.Fake <Action <ReadOnlyMemory <byte> > >();

        data.ForEachSegment(handler);

        A.CallTo(() => handler.Invoke(segment)).MustHaveHappened();
    }
Beispiel #4
0
    public async Task ForEachSegment_Invokes_Async_Handler_For_Single_Segment()
    {
        var segment = Guid.NewGuid().ToByteArray().AsMemory();
        var data    = new ReadOnlySequence <byte>(segment);
        var handler = A.Fake <Func <ReadOnlyMemory <byte>, CancellationToken, Task> >();

        await data.ForEachSegment(handler, default);

        A.CallTo(() => handler.Invoke(segment, A <CancellationToken> ._)).MustHaveHappened();
    }