Exemplo n.º 1
0
        public void JobApplicationQueryObjectTest()
        {
            var unit = new UnitOfWork(GetInMemoryOptions());

            Seeder.Seed(unit);

            unit.JobOfferQuery.FilterByCompanyName("Apple").OrderBy(o => o.Name, false);
            var offers = unit.JobOfferQuery.ExecuteAsync().Result;

            Assert.Equal(2, offers.Count()); // Apple should have 1 offer
            var offer = offers.First();

            Assert.NotNull(offer);
            Assert.Equal("Well-paid position at Apple", offer.Name);

            var queryObject = new JobApplicationQueryObject(unit);

            Assert.Equal(2, queryObject.GetByJobOfferIdAsync(offer.Id ?? -1)
                         .Result
                         .Count());
            Assert.Equal(new List <string>()
            {
                "Jason", "Neo"
            },
                         queryObject.GetByJobOfferIdAsync(offer.Id ?? -1)
                         .Result
                         .Select(a => a.Applicant?.Name));
            Assert.Equal(new List <string>()
            {
                "Neo"
            },
                         queryObject.GetByJobOfferIdAndStatusAsync(offer.Id ?? -1, Status.Rejected)
                         .Result
                         .Select(a => a.Applicant?.Name));

            int neoId = queryObject.GetByJobOfferIdAndStatusAsync(offer.Id ?? -1, Status.Rejected)
                        .Result
                        .Select(a => a.Applicant?.Id)
                        .First() ?? -1;

            Assert.Equal(new List <string>()
            {
                "Microsoft > Apple", "Blue pill, red pill, I'll eat both"
            },
                         queryObject.GetByApplicantIdAsync(neoId)
                         .Result
                         .Select(a => a.Text));

            Assert.Equal(new List <string>()
            {
                "Blue pill, red pill, I'll eat both"
            },
                         queryObject.GetByApplicantIdAndStatusAsync(neoId, Status.Rejected)
                         .Result
                         .Select(a => a.Text));

            unit.Dispose();
        }
Exemplo n.º 2
0
 public JobApplicationService(UnitOfWork unitOfWork, JobApplicationQueryObject jobApplicationQueryObject)
 {
     this.unitOfWork = unitOfWork;
     this.jobApplicationQueryObject = jobApplicationQueryObject;
 }