コード例 #1
0
            public DIPService()
            {
                WorkService workService = new WorkService(new Logger(), new Storage(), new Combiner());

                workService.DoWork("ED");
                workService.DoWork("Tarnya");
            }
コード例 #2
0
        public void TestDIP()
        {
            var              loggerMock   = new Mock <ILogger>();
            Mock <IStorage>  storageMock  = new Mock <IStorage>();
            Mock <ICombiner> combinerMock = new Mock <ICombiner>();

            loggerMock.Setup(m => m.log(It.IsAny <string>()));
            combinerMock.Setup(s => s.Combine(It.IsAny <string>(), It.IsAny <string>())).Returns("FakeString");
            WorkService workService = new WorkService(loggerMock.Object, new Storage(), new Combiner());

            workService.DoWork("ED");

            loggerMock.Verify(x => x.log(It.IsAny <string>()), Times.Exactly(3));
        }