public void Validate() { var collection = MongoContext.ApplicationsCollection(); IMongoQueryable <JobApplication> query = collection.AsQueryable(); var app = query.Where(x => x._id == ObjectId.Parse(this.Application_Id)).First(); if (this.Answers != null && this.Answers.Count == app.Questions.Count) { foreach (UserAnswer tempAnswer in this.Answers) { var question = app.Questions.Where(x => x.QuestionText == tempAnswer.QuestionText).FirstOrDefault(); if (question != null) { tempAnswer.Correct = question.Answers.Where(x => x.AnswerText == tempAnswer.AnswerText).Select(x => x.Correct).First(); } } this.Complete = true; this.Passed = !this.Answers.Where(x => x.Correct == false).Any(); } else { this.Complete = false; } }
public void CollectionsExist() { var collectionResults = new List <bool>(); var users = MongoContext.UsersCollection(); var results = MongoContext.ResultsCollection(); var apps = MongoContext.ApplicationsCollection(); collectionResults.Add(users == null ? false : true); collectionResults.Add(results == null ? false : true); collectionResults.Add(apps == null ? false : true); Assert.AreEqual(collectionResults.Contains(false), false); }
public ApplicationService() { collection = MongoContext.ApplicationsCollection(); }