public void When()
        {
            using (var session = OpenSession())
            {
                DateTimeProvider.Now = () => new DateTime(2012, 10, 11);
                var query = new TweedehandsQuery(Guid.NewGuid(), "VW", "Cars", "*****@*****.**");
                query.ChangeStatus(Status.Confirmed);

                session.Store(query);
                session.SaveChanges();

                _queryId = query.Id;
            }

            var proxy = new Mock<IQueryService>();
            proxy
                .Setup(p => p.Query("belgium", "Cars", "VW"))
                .Returns(new TweedehandsAlert.BackgroundWorker.Query.Proxy.QueryResult()
                {
                    Items = new List<ResultItem>() {
                        new ResultItem()
                        {
                            DateTime = new ResultItemDateTime()
                            {
                                Value = new DateTime(2012, 10, 10)
                            },
                            Url = @"http://www.test.be/1" ,
                            Title = new ResultTitle()
                            {
                                Value = "Test 1"
                            }
                        },
                        new ResultItem()
                        {
                            DateTime = new ResultItemDateTime()
                            {
                                Value = new DateTime(2012, 10, 12)
                            },
                            Url = @"http://www.test.be/2",
                            Title = new ResultTitle()
                            {
                                Value = "Test 2"
                            }

                        }
                    }
                });

            DateTimeProvider.Now = () => new DateTime(2012, 10, 12);
            var job = new QueryJob(proxy.Object);
            job.Execute(new Mock<IJobExecutionContext>().Object);
        }
        public void When()
        {
            using (var session = OpenSession())
            {
                DateTimeProvider.Now = () => new DateTime(2012, 10, 11);

                var query = new TweedehandsQuery(Guid.NewGuid(), "Carzzz", "Category", "*****@*****.**");
                query.ChangeStatus(Status.Confirmed);

                session.Store(query);

                _querId = query.Id;

                var queryCollection1 = new QueryResultCollection(query.Id, new List<QueryResult>()
                {
                    new QueryResult(new DateTime(2010, 10, 10), "Test 1", "http://www.test.be/1"),
                    new QueryResult(new DateTime(2010, 10, 11), "Test 2", "http://www.test.be/2"),
                });
                var queryCollection2 = new QueryResultCollection(query.Id, new List<QueryResult>()
                {
                    new QueryResult(new DateTime(2010, 10, 12), "Test 3", "http://www.test.be/3"),
                    new QueryResult(new DateTime(2010, 10, 13), "Test 4", "http://www.test.be/4"),
                });

                session.Store(queryCollection1);
                session.Store(queryCollection2);

                _collectionId1 = queryCollection1.Id;
                _collectionId2 = queryCollection2.Id;

                session.SaveChanges();
            }

            DateTimeProvider.Now = () => new DateTime(2012, 10, 12);

            _mailGun = new Mock<IMailGun>();
            var mailJob = new AlertJob(_mailGun.Object);
            mailJob.Execute(new Mock<IJobExecutionContext>().Object);
        }