From 1d50d3d7360100e9d1c6545b4a937880291c3d9b Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 15 Feb 2019 09:43:23 +0100 Subject: [PATCH] SEBWIN-296: Extended unit tests for base proxy. --- .../Proxies/BaseProxyTests.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/SafeExamBrowser.Communication.UnitTests/Proxies/BaseProxyTests.cs b/SafeExamBrowser.Communication.UnitTests/Proxies/BaseProxyTests.cs index 9fab7b3d..9515b6b1 100644 --- a/SafeExamBrowser.Communication.UnitTests/Proxies/BaseProxyTests.cs +++ b/SafeExamBrowser.Communication.UnitTests/Proxies/BaseProxyTests.cs @@ -361,5 +361,27 @@ namespace SafeExamBrowser.Communication.UnitTests.Proxies Assert.IsTrue(lost); } + + [TestMethod] + public void MustLogStatusChanges() + { + var proxy = new Mock(); + var connectionLost = false; + + proxyObjectFactory.Setup(f => f.CreateObject(It.IsAny())).Returns(proxy.Object); + sut.ConnectionLost += () => connectionLost = true; + sut.Connect(Guid.Empty); + + proxy.Raise(p => p.Closed += null, It.IsAny()); + proxy.Raise(p => p.Closing += null, It.IsAny()); + proxy.Raise(p => p.Faulted += null, It.IsAny()); + proxy.Raise(p => p.Opened += null, It.IsAny()); + proxy.Raise(p => p.Opening += null, It.IsAny()); + + logger.Verify(l => l.Debug(It.IsAny()), Times.AtLeast(4)); + logger.Verify(l => l.Warn(It.IsAny()), Times.AtLeastOnce); + + Assert.IsTrue(connectionLost); + } } }