Example #1
0
        public void DoStuff_GivenStuff_ExpectedStuff()
        {
            //Arrange
            ISomeRepository      repository = A.Fake <ISomeRepository>();
            ISomeClient          client     = A.Fake <ISomeClient>();
            ISomeLogger          logger     = A.Fake <ISomeLogger>();
            IImprovedSomeService service    = new DependencyInjectionMakesUnitTestingSimple.ImprovedSomeService(repository,
                                                                                                                client,
                                                                                                                logger);
            //Act
            var result = service.DoStuff();

            //Assert
            A.CallTo(() => repository.WriteStuffToDb()).MustHaveHappened();
            A.CallTo(() => client.SomeCallToWebService()).MustHaveHappened();
            A.CallTo(() => logger.LogStuff()).MustHaveHappened();
            Assert.True(result);
        }
Example #2
0
        public ImprovedSomeService(ISomeRepository someRepository,
                                   ISomeClient someClient,
                                   ISomeLogger someLogger)
        {
            if (someRepository == null)
            {
                throw new ArgumentNullException(nameof(someRepository));
            }
            if (someClient == null)
            {
                throw new ArgumentNullException(nameof(someClient));
            }
            if (someLogger == null)
            {
                throw new ArgumentNullException(nameof(someLogger));
            }

            this.SomeRepository = someRepository;
            this.SomeClient     = someClient;
            this.SomeLogger     = someLogger;
        }
        public ImprovedSomeService(ISomeRepository someRepository,
            ISomeClient someClient,
            ISomeLogger someLogger)
        {
            if (someRepository == null)
            {
                throw new ArgumentNullException(nameof(someRepository));
            }
            if (someClient == null)
            {
                throw new ArgumentNullException(nameof(someClient));
            }
            if (someLogger == null)
            {
                throw new ArgumentNullException(nameof(someLogger));
            }

            this.SomeRepository = someRepository;
            this.SomeClient = someClient;
            this.SomeLogger = someLogger;
        }
Example #4
0
 public LoggingDecorator(IQuoteProcessor quoteProcessor, ISomeLogger logger)
 {
     _quoteProcessor = quoteProcessor;
     _logger         = logger;
 }