Esempio n. 1
0
        public void TesteCriarCompraMockCompraService()
        {
            var mockService = new Mock <ICompraService>();

            mockService.Setup(x => x.CriarCompra(new Compra()));
            var controller = new CompraController(mockService.Object)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };
            var response = controller.CriarCompra(new CompraModel()
            {
                StatusCompra = "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);
        }