public void NotaFiscal_IntegracaoSistema_Emitir_DeveEmitirOk() { NotaFiscal nota = ObjectMother.ObterNotaValida(); Action action = () => notaFiscalServico.Emitir(nota); action.Should().NotThrow(); }
public void NotaFiscal_Aplicacao_Emitir_DeveEmitirOk() { NotaFiscal nota = ObjectMother.ObterNotaValida(); mockRepositorio.Setup(x => x.Salvar(nota)).Returns(new NotaFiscal() { Id = 1, Emitido = true }); NotaFiscal novaNota = notaFiscalServico.Emitir(nota); novaNota.Id.Should().BeGreaterThan(0); novaNota.Emitido.Should().BeTrue(); mockRepositorio.Verify(x => x.Salvar(nota)); mockRepositorio.VerifyNoOtherCalls(); }
public void NotaFiscal_Aplicacao_Emitir_ComFakeParaRepetirChaveDeAcesso_Sucesso() { long idAposAdicionar = 1; string xmlObitdo = ""; FakeNotaFiscalEmitidaRepositorio fakeNotaFiscalEmitidaRepositorio = new FakeNotaFiscalEmitidaRepositorio(); NotaFiscalServico _servicoNotaFiscalComRepositorioFake = new NotaFiscalServico(_mockNotaFiscalRepositorio.Object, fakeNotaFiscalEmitidaRepositorio, _mockProdutoNotaFiscalRepositorio.Object, _mockNotaFiscalRepositorioXML.Object); Mock <Random> mockRandom = new Mock <Random>(); _mockNotaFiscal.Setup(mnf => mnf.CalcularValoresTotais()); _mockNotaFiscal.Setup(mnf => mnf.ValidarParaEmitir()); _mockNotaFiscal.Setup(mnf => mnf.GerarChaveDeAcesso(mockRandom.Object)); _mockNotaFiscal.Setup(mnf => mnf.Id).Returns(idAposAdicionar); //Setup mock nota fiscal repositorio _mockNotaFiscalRepositorio.Setup(mnfr => mnfr.Excluir(_mockNotaFiscal.Object)); _mockNotaFiscalRepositorioXML.Setup(mnfrx => mnfrx.Serializar(_mockNotaFiscal.Object)).Returns(xmlObitdo); //Acao _servicoNotaFiscalComRepositorioFake.Emitir(_mockNotaFiscal.Object, mockRandom.Object); //Verificacoes _mockNotaFiscal.Verify(mnf => mnf.ValidarParaEmitir()); _mockNotaFiscal.Verify(mnf => mnf.GerarChaveDeAcesso(mockRandom.Object)); _mockNotaFiscal.Verify(mnf => mnf.ChaveAcesso); _mockNotaFiscalRepositorio.Verify(mnfr => mnfr.Excluir(_mockNotaFiscal.Object)); _mockNotaFiscalRepositorioXML.Verify(mnfrx => mnfrx.Serializar(_mockNotaFiscal.Object)); }