Exemplo n.º 1
0
        public void Get_ById_Test()
        {
            //Arange
            var stubScriptService = new Mock <IScriptService>();
            var stubMapper        = new Mock <IScriptMapper>();

            var script = new Script
            {
                ScriptId = 1
            };

            var transferScript = new TransferScript
            {
                ScriptId = 1
            };

            stubScriptService.Setup(ss => ss.FetchScriptById(1))
            .Returns(script);
            stubMapper.Setup(m => m.Map(script))
            .Returns(transferScript);

            var controller = new ScriptController(stubScriptService.Object,
                                                  stubMapper.Object, new CookieParser());

            //Act
            var actual = controller.Get(1);

            //Assert
            Assert.That(actual.ScriptId == script.ScriptId);

            stubMapper.Verify(m => m.Map(script),
                              Times.Once);

            stubScriptService.Verify(ss => ss.FetchScriptById(1),
                                     Times.Once);
        }