예제 #1
0
        public void TesteCriarVendaMockVendaService()
        {
            var mockService = new Mock <IVendaService>();

            mockService.Setup(x => x.CriarVenda(new Venda()));
            var controller = new VendaController(mockService.Object)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };
            var response = controller.CriarVenda(new VendaModel()
            {
                Status = "Aberto"
            });
            var data = response.Result.Content.ReadAsAsync <RetornoBase <object> >();

            Assert.AreEqual(HttpStatusCode.OK, response.Result.StatusCode);
            Assert.AreEqual(null, data.Result.ObjetoRetorno);
            Assert.AreEqual(false, data.Result.TemErros);
            Assert.AreEqual(Mensagens.ReturnSuccess, data.Result.Mensagem);
        }