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();
        }
Exemple #2
0
 public async Task <IEnumerable <JobApplication> > GetByJobOfferIdAsync(int jobOfferId)
 {
     return(await jobApplicationQueryObject.GetByJobOfferIdAsync(jobOfferId));
 }