コード例 #1
0
        public async void Cadastrar_test_BadRequest()
        {
            //Given

            var queryMock   = new Mock <IPedidoQuery>();
            var commandMock = new Mock <IPedidoCommand>();

            var faker = AutoFaker.Create();

            var param = faker.Generate <PedidoParam>();

            var response = "Pedido não aceito";

            var baseControllerMock = new PedidoController(commandMock.Object, queryMock.Object, "User");
            var expectResponse     = baseControllerMock.BadRequest(response);


            commandMock.Setup(r => r.InserirPedido(It.IsAny <PedidoParam>())).ReturnsAsync(false).Verifiable();

            //When

            var result = await baseControllerMock.Cadastrar(param);

            //Then
            var comparison = new CompareLogic();

            commandMock.Verify(mock => mock.InserirPedido(It.IsAny <PedidoParam>()), Times.Once());
            Assert.True(comparison.Compare(result, expectResponse).AreEqual);
        }