public void ExecuteAsync_WithTransportConnectionAsyncClosed_InvokesConnectAsync() { var transportMock = new Mock <ITransport>(); transportMock.Setup(t => t.State).Returns(TransportState.Closed); transportMock.Setup(t => t.SendAsync(It.IsAny <ReadOnlySequence <byte> >(), default)) .ReturnsAsync(new ReadOnlySequence <byte>(Encoding.UTF8.GetBytes($"+foo\r\n"))); var target = new RespClient(new RedisCacheOptions { Host = "foo" }, transportMock.Object); var request = Mock.Of <IRequest>(r => r.Command == "foo" && r.GetArgs() == Array.Empty <object>()); var response = target.ExecuteAsync(request); Assert.IsNotNull(response); transportMock.Verify(t => t.ConnectAsync(default), Times.Once());
public async Task ExecuteAsync_RequestsIsEmpty_Throws() { var target = new RespClient(new RedisCacheOptions { Host = "foo" }); var requests = Array.Empty <IRequest>(); var e = await Assert.ThrowsExceptionAsync <ArgumentException>(() => target.ExecuteAsync(requests)); Assert.AreEqual(e.ParamName, "requests"); }
public async Task ExecuteAsync_RequestsIsNull_Throws() { var target = new RespClient(new RedisCacheOptions { Host = "foo" }); IRequest[] requests = null; var e = await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => target.ExecuteAsync(requests)); Assert.AreEqual(e.ParamName, "requests"); }