コード例 #1
0
        public void LogsTimeOnInvalidGet()
        {
            var log        = new Log();
            var clock      = new StaticClock();
            var repository = new RecipeRepositoryUsingDependencyInjection(log, clock);

            repository.Invoking(r => r.Get(Guid.NewGuid())).ShouldThrow <ArgumentException>();

            log.Get().First().Time.Should().Be(clock.Now);
        }
コード例 #2
0
        public void LogsInvalidGetWithMock()
        {
            var log = new Mock <ILog>();

            log.Setup(l => l.Error(It.IsAny <DateTime>(), It.IsAny <string>()));
            var clock = new Mock <IClock>();

            var repository = new RecipeRepositoryUsingDependencyInjection(log.Object, clock.Object);

            repository.Invoking(r => r.Get(Guid.NewGuid())).ShouldThrow <ArgumentException>();

            log.Verify(l => l.Error(It.IsAny <DateTime>(), It.IsAny <string>()), Times.Exactly(1));
        }
コード例 #3
0
 public RecipeCounter(SystemClock clock, RecipeRepositoryUsingDependencyInjection repository)
 {
     _clock      = clock;
     _repository = repository;
 }