コード例 #1
0
        public void AoAcessarACamadaDeNegociosDaPaginaDeListagemEOcorreUmaExcecao_AExcecaoDeveSerLancadaParaCamadaSuperior()
        {
            var repository = new Mock<IProductRepository>();
            repository.Setup(x => x.RecuperarTodosProdutos()).Throws<Exception>();

            var business = new ProductBusiness(repository.Object);

            Assert.Throws<Exception>(() => business.GetAll());
        }
コード例 #2
0
        public void AoAcessarACamadaDeNegociosDaPaginaDeVisualizacaoEOcorrerUmaExcecao_AExcecaoDeveSerLancadaParaCamadaSuperior()
        {
            const int id = 1;

            var repository = new Mock<IProductRepository>();

            repository.Setup(x => x.RecuperarInformacoesDoLivro(id)).Throws<Exception>();

            var business = new ProductBusiness(repository.Object);

            Assert.Throws<Exception>(() => business.GetInfo(id));
        }
コード例 #3
0
 public void SetUp()
 {
     _repository = new Mock<IProductRepository>();
     _business = new ProductBusiness(_repository.Object);
 }