public void ObterEstatisticaDoAnuncio_Anuncio_Valido_Chama_Repositorio_ObterEstatisticaDoAnuncio_Retorna_Estatistica() { Anuncio anuncio = new Anuncio(null, new Automovel(new Modelo()), null); EstatisticaAnuncio estatistaAnuncio = new EstatisticaAnuncio(anuncio); repositorioEstatisticaAnuncioMock.Setup(r => r.ObterEstatisticaDoAnuncio(anuncio)).Returns(estatistaAnuncio); Assert.AreEqual(estatistaAnuncio, target.ObterEstatisticaDoAnuncio(anuncio)); repositorioEstatisticaAnuncioMock.Verify(r => r.ObterEstatisticaDoAnuncio(anuncio)); }
public void VisualizarAnuncio_Anuncio_Com_Estatistica_Incrementa_VisualizacoesAnuncio_Chama_Repositorio_Incluir_Atualizar() { uint visitas = 10; Anuncio anuncio = new Anuncio(null, new Automovel(new Modelo()), null); EstatisticaAnuncio estatistaAnuncio = new EstatisticaAnuncio(anuncio) { VisualizacoesAnuncio = visitas } ; repositorioEstatisticaAnuncioMock.Setup(r => r.ObterEstatisticaDoAnuncio(anuncio)).Returns(estatistaAnuncio); target.VisualizarAnuncio(anuncio); repositorioEstatisticaAnuncioMock.Verify(r => r.ObterEstatisticaDoAnuncio(anuncio)); repositorioEstatisticaAnuncioMock.Verify(r => r.Atualizar(estatistaAnuncio)); Assert.AreEqual(++visitas, estatistaAnuncio.VisualizacoesAnuncio); }
public void Anunciar_Anuncio_Valido_Chama_Servico_Incluir_Anunciante_Automovel__Estatistica_DataAnuncio_Atual_Status_AguardandoAprovacao() { Automovel automovel = new Automovel(new Modelo()) { ParcelasRestantes = 1, ValorParcela = 10.00M }; Anunciante anunciante = new Anunciante(); Anuncio anuncio = new Anuncio(anunciante, automovel, new Plano() { Ativo = true }); EstatisticaAnuncio estatisticaAnuncio = new EstatisticaAnuncio(anuncio); target.Anunciar(anuncio); servicoAnuncianteMock.Verify(s => s.Incluir(anunciante)); repositorioAutomovelMock.Verify(s => s.Incluir(automovel)); repositorioEstatisticaAnuncioMock.Verify(s => s.Incluir(estatisticaAnuncio)); repositorioAnuncioMock.Verify(s => s.Anuciar(anuncio)); Assert.AreEqual(DateTime.Now.ToShortDateString(), anuncio.Data.ToShortDateString()); Assert.AreEqual(StatusAnuncio.AguardandoAprovacao, anuncio.Status); }
public void Excluir_Anuncio_Valido_Chama_Servico_Excluir_Automovel_Repositorio_Excluir() { Automovel automovel = new Automovel(new Modelo()); Anunciante anunciante = new Anunciante(); Anuncio anuncio = new Anuncio(anunciante, automovel, new Plano() { Ativo = true }); EstatisticaAnuncio estatisticaAnuncio = new EstatisticaAnuncio(anuncio); repositorioEstatisticaAnuncioMock.Setup(s => s.ObterEstatisticaDoAnuncio(anuncio)).Returns(estatisticaAnuncio); target.Excluir(anuncio); repositorioAutomovelMock.Verify(s => s.Excluir(automovel)); repositorioEstatisticaAnuncioMock.Verify(s => s.Excluir(estatisticaAnuncio)); repositorioAnuncioMock.Verify(s => s.Excluir(anuncio)); }