예제 #1
0
        public void Warm_WhenProvidingDelegate_ThenRunDelegate()
        {
            var mockConfig = MockConfig();
            var mockRequester = MockRequester();
            var mockLogger = MockLogger();
            var warmer = new CustomWarmer(mockConfig.Object, mockRequester.Object);
            var logger = mockLogger.Object;

            warmer.Warm(logger.Log);

            mockRequester.Verify(f => f.Check(It.IsAny<Check>()), Times.Exactly(2));
            mockLogger.Verify(f => f.Log(It.IsAny<Check>()), Times.Exactly(2));
        }
예제 #2
0
        public void Warm_WhenProvidingMultiCallDelegate_ThenRunDelegate()
        {
            var mockConfig = MockConfig();
            var mockRequester = MockRequester();
            var mockLogger = MockLogger();
            var warmer = new CustomWarmer(mockConfig.Object, mockRequester.Object);
            var logger = mockLogger.Object;

            var tracker = 0;

            warmer.Warm(
                delegate(Check check)
                    {
                        logger.Log(check);
                        tracker++;
                    }
                );

            mockRequester.Verify(f => f.Check(It.IsAny<Check>()), Times.Exactly(2));
            mockLogger.Verify(f => f.Log(It.IsAny<Check>()), Times.Exactly(2));
            Assert.That(tracker, Is.EqualTo(2));
        }