public async Task Diagnose_CorrectConnection_CorrectResult() { var messageAdapter = new Mock <IMessageAdapter>(); var messageAdapterConstructor = new Mock <IMessageAdapterConstructor>(); messageAdapter.Setup(x => x.Configuration) .Returns(CreateConnection()); messageAdapter.Setup(x => x.Connect()); messageAdapter.Setup(x => x.Disconnect()); messageAdapterConstructor.Setup(x => x.CreateAll(It.IsAny <bool>())) .Returns(new[] { messageAdapter.Object }); var checker = new MessagingConnectionChecker(new[] { messageAdapterConstructor.Object }); var result = await checker.Diagnose(); var diagnosticInfo = result.First(); Assert.Multiple(() => { Assert.That(diagnosticInfo.Error, Is.EqualTo(string.Empty)); Assert.That(diagnosticInfo.Status, Is.EqualTo(DiagnosticStatus.Ok)); Assert.That(diagnosticInfo.IsSkipResult, Is.False); Assert.That(diagnosticInfo.Name, Is.EqualTo(MqSeriesId)); Assert.That(diagnosticInfo.Url, Is.EqualTo(MqSeriesServer)); Assert.That(diagnosticInfo.Version, Is.EqualTo(string.Empty)); }); }
public async Task Diagnose_ErrorOnCreateAll_ErrorResult() { var errorConnect = "Error_connect"; var messageAdapterConstructor = new Mock <IMessageAdapterConstructor>(); messageAdapterConstructor.Setup(x => x.CreateAll(It.IsAny <bool>())) .Throws(new Exception(errorConnect)); var checker = new MessagingConnectionChecker(new[] { messageAdapterConstructor.Object }); var result = await checker.Diagnose(); var diagnosticInfo = result.First(); Assert.Multiple(() => { Assert.That(diagnosticInfo.Error.Contains(errorConnect), Is.True); Assert.That(diagnosticInfo.Status, Is.EqualTo(DiagnosticStatus.ConfigError)); Assert.That(diagnosticInfo.IsSkipResult, Is.False); Assert.That(diagnosticInfo.Name, Is.EqualTo("constructor")); Assert.That(diagnosticInfo.Url, Is.Null); Assert.That(diagnosticInfo.Version, Is.EqualTo(string.Empty)); }); }
public async Task Diagnose_NoConstructors_EmptyResult() { var checker = new MessagingConnectionChecker(new IMessageAdapterConstructor[0]); var result = await checker.Diagnose(); Assert.That(result, Is.Empty); }
public async Task Diagnose_NoAdaptersReturned_EmptyResult() { var messageAdapterConstructor = new Mock <IMessageAdapterConstructor>(); messageAdapterConstructor.Setup(x => x.CreateAll(It.IsAny <bool>())) .Returns(new IMessageAdapter[0]); var checker = new MessagingConnectionChecker(new[] { messageAdapterConstructor.Object }); var result = await checker.Diagnose(); Assert.That(result, Is.Empty); }
public async Task Diagnose_NoHealthCheckConnections_EmptyResult() { var messageAdapter = new Mock <IMessageAdapter>(); var messageAdapterConstructor = new Mock <IMessageAdapterConstructor>(); messageAdapter.Setup(x => x.Configuration) .Returns(CreateConnection(false)); messageAdapter.Setup(x => x.Connect()); messageAdapter.Setup(x => x.Disconnect()); messageAdapterConstructor.Setup(x => x.CreateAll(It.IsAny <bool>())) .Returns(new[] { messageAdapter.Object }); var checker = new MessagingConnectionChecker(new[] { messageAdapterConstructor.Object }); var result = await checker.Diagnose(); Assert.That(result, Is.Empty); }