Beispiel #1
0
        public void SetUp()
        {
            var mockAdicionarNovoPorcessoResponse = new AdicionarNovoPorcessoResponse {
                IdProcesso = Guid.NewGuid(), StatusCode = HttpStatusCode.Accepted
            };
            var mockObterProcessoPorResponse = new ObterProcessoPorResponse {
                StatusCode = HttpStatusCode.OK, Processo = CriarMockTorreHanoiCompletaDto()
            };
            var mockObterTodosProcessosResponse = new ObterTodosProcessosResponse {
                StatusCode = HttpStatusCode.OK, Processos = CriarMockTorreHanoiResumoDto()
            };

            var mockTorreHanoiApplicationService = new Mock <ITorreHanoiApplicationService>();

            mockTorreHanoiApplicationService.Setup(s => s.AdicionarNovoPorcesso(It.IsAny <int>())).Returns(() => mockAdicionarNovoPorcessoResponse);
            mockTorreHanoiApplicationService.Setup(s => s.ObterProcessoPor(It.Is <string>(id => id.Equals(_idProcesso)))).Returns(() => mockObterProcessoPorResponse);
            mockTorreHanoiApplicationService.Setup(s => s.ObterTodosProcessos()).Returns(() => mockObterTodosProcessosResponse);

            _controller =
                new TorreHanoiController(mockTorreHanoiApplicationService.Object)
            {
                Request = new HttpRequestMessage()
            };
            _controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
        }
        internal static AdicionarNovoPorcessoResponse Validation(this int numeroDiscos)
        {
            var response = new AdicionarNovoPorcessoResponse();

            if (numeroDiscos >= 1)
            {
                return(response);
            }
            response.AdicionarMensagemDeErro("É necessario ao menos um disco para executar a torre de hanoi");
            response.StatusCode = System.Net.HttpStatusCode.BadRequest;

            return(response);
        }