public void FlushVisitorAsyncTest() { var visitorCache = new Mock <IVisitorCacheImplementation>(); var visitorId = visitorDelegate.VisitorId; visitorDelegate.Config.VisitorCacheImplementation = visitorCache.Object; var defaultStrategy = new DefaultStrategy(visitorDelegate); defaultStrategy.FlushVisitorAsync(); visitorCache.Verify(x => x.FlushVisitor(visitorId), Times.Once()); var error = new Exception("visitorCache error"); visitorCache.Setup(x => x.FlushVisitor(It.IsAny <string>())).Throws(error); defaultStrategy.FlushVisitorAsync(); fsLogManagerMock.Verify(x => x.Error(error.Message, "FlushVisitor"), Times.Once()); }