public void SetUp()
        {
            var database = new Mock <IDatabase>();

            database.Setup(x => x.Query <PizzaRecord>()).Throws(new Exception("Something went wrong"));

            var subject = new PizzaRepository(database.Object);

            _result = subject.GetAll();
        }
Exemplo n.º 2
0
        public GetPizzasResponse GetAll()
        {
            GetPizzasResponse   result = new GetPizzasResponse();
            IEnumerable <Pizza> allPizzas;

            try
            {
                allPizzas     = _pizzaRepository.FindAll();
                result.Pizzas = allPizzas.ConvertToViewModels();
            }
            catch (Exception ex)
            {
                result.StatusCode       = HttpStatusCode.InternalServerError;
                result.StatusDesciption = ex.Message;
            }

            return(result);
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            var database = new Mock <IDatabase>();

            database.Setup(x => x.Query <PizzaRecord>()).Returns(new List <PizzaRecord>
            {
                new PizzaRecord
                {
                    Id   = 1,
                    Name = "Original"
                },
                new PizzaRecord
                {
                    Id   = 2,
                    Name = "Gimme the Meat"
                }
            });

            var subject = new PizzaRepository(database.Object);

            _result = subject.GetAll();
        }