Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Scretch9 committed Dec 14, 2023
1 parent e6ef940 commit be90049
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/FieldElementSubsystems.Test/Point/PointTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,37 @@ public async Task Test_Send_Generic_Message()
Message = ByteString.CopyFrom (rawBytes)
};

var point = CreateDefaultPoint(mockConnection.Object);
mockConnection
.SetupSequence(m => m.SendGenericMessage(rawBytes))
.SetupSequence(m => m.ReceivePointPosition(It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<GenericPointPosition?>(null))
.Returns(async () =>
{
await point.SendGenericMessage(genericMessage);
return null;
})
.Returns(() =>
{
cancel.Cancel();
return new TaskCompletionSource<GenericPointPosition?>().Task;
});

var args = new List<byte[]>();

mockConnection
.SetupSequence(m => m.SendGenericMessage(Capture.In(args)))
.Returns(() =>
{
cancel.Cancel();
return new TaskCompletionSource<GenericPointPosition?>().Task;
});

var point = CreateDefaultPoint(mockConnection.Object);

// Act
await point.StartAsync(cancel.Token);
await point.SendGenericMessage(genericMessage);

// Assert
mockConnection.Verify(v => v.SendGenericMessage(rawBytes), Times.Once());
Assert.Equal(rawBytes, args.ToArray()[0]);
}

[Fact]
Expand Down

0 comments on commit be90049

Please sign in to comment.