public void GivenIHaveAStartedReviewWithCategoriesAndAdditionalPeers(int numberOfCategories, int numberOfPeers) { GivenIOwnAReview(); var reviewId = ScenarioContext.Current.Get <ReviewConfiguration>().Id; using (var ctx = new DelayedDatabaseContext()) { var reviewConfiguration = ctx.ReviewConfigurations.Find(reviewId); for (var i = 0; i < numberOfCategories; i++) { reviewConfiguration.Categories.Add(new ReviewCategory { Name = "cat" + i, Description = "desc" + i }); } for (var i = 0; i < numberOfPeers; i++) { reviewConfiguration.Peers.Add(new UserProfile { EmailAddress = i + _emailDomain, UserName = "******" + i }); } reviewConfiguration.ReviewRounds.Add(new ReviewRound { Active = true, StartDate = DateTime.UtcNow }); ctx.SaveChanges(); ScenarioContext.Current.Set(reviewConfiguration); } }
public void GivenAllPeersHaveProvidedTheReview() { var reviewId = ScenarioContext.Current.Get <ReviewConfiguration>().Id; using (var ctx = new DelayedDatabaseContext()) { var reviewConfiguration = ctx.ReviewConfigurations.Find(reviewId); ctx.Entry(reviewConfiguration).Collection(c => c.Categories).Load(); ctx.Entry(reviewConfiguration).Collection(c => c.Peers).Load(); foreach (var reviewer in reviewConfiguration.Peers) { var newFeedback = new ReviewFeedback(); foreach (var reviewCategory in reviewConfiguration.Categories) { foreach (var peer in reviewConfiguration.Peers) { newFeedback.Assessments.Add(new Assessment { ReviewCategory = reviewCategory, Rating = 7, Reviewer = reviewer, ReviewedPeer = peer }); } } newFeedback.Reviewer = reviewer; var reviewRound = new ReviewRound { Active = true, StartDate = DateTime.UtcNow }; reviewRound.Feedback.Add(newFeedback); reviewConfiguration.ReviewRounds.Add(reviewRound); } ctx.SaveChanges(); ScenarioContext.Current.Set(reviewConfiguration); } }
public void ThenTheReviewIsActive() { using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving review from DB"); var reviewFromDb = ctx.ReviewConfigurations.Single(); Assert.IsTrue(reviewFromDb.ReviewRounds.Any(round => round.Active)); } }
public void ThenTheFeedbackIsNotSaved() { using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving review from DB"); var reviewFromDb = ctx.ReviewConfigurations.Include("Feedback").Single(); Assert.IsFalse(reviewFromDb.ReviewRounds.Any(round => round.Feedback.Any())); } }
public void WhenIFinishLogin() { _browser.FindId("Login").Click(); using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving user from DB"); ScenarioContext.Current.Set(ctx.UserProfiles.Single()); } }
public void WhenNoAccountExistsForThatPeerSEmailAddress() { using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Trying to retrieve peer from DB"); var peerAddress = ScenarioContext.Current.Get <UserProfile>("peer").EmailAddress; var peerFromDb = ctx.UserProfiles.SingleOrDefault(user => user.EmailAddress == peerAddress); Assert.IsNull(peerFromDb); } }
public void ThenANewAccountWasCreatedWithMyGoogleAddress() { var emailAddress = ScenarioContext.Current.Get <Email>().Address; using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving user from DB"); Assert.That(ctx.UserProfiles.Single().EmailAddress, Is.EqualTo(emailAddress)); } }
public void GivenIRegisteredStandardly() { WhenIRegisterANewAccount(); WhenIFillInMyEmailAddress("*****@*****.**"); WhenIFinishRegistering(); using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving user from DB"); ScenarioContext.Current.Set(ctx.UserProfiles.Single()); } }
public void ThenANewUserWithTheGivenNameAndEmailAddressWasCreated() { using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Trying to retrieve peer from DB"); var peer = ScenarioContext.Current.Get <UserProfile>("peer"); var peerFromDb = ctx.UserProfiles.SingleOrDefault( user => user.EmailAddress == peer.EmailAddress && user.UserName == peer.UserName); Assert.IsNotNull(peerFromDb); } }
public void ThenIAmAddedToTheReview() { var thisIsMe = ScenarioContext.Current.Get <UserProfile>(); using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving review from DB"); var reviewFromDb = ctx.ReviewConfigurations.Include("Peers").Single(); Assert.That(reviewFromDb.Peers.Count, Is.EqualTo(1)); Assert.That(reviewFromDb.Peers[0].Id, Is.EqualTo(thisIsMe.Id)); } }
public void ThenThisUserIsAddedToTheReview() { var peer = ScenarioContext.Current.Get <UserProfile>("peer"); using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving review from DB"); var reviewFromDb = ctx.ReviewConfigurations.Include("Peers").Single(); Assert.AreEqual(1, reviewFromDb.Peers.Count( user => user.EmailAddress == peer.EmailAddress && user.UserName == peer.UserName)); } }
public void WhenIVisitTheProvideReviewUrlFor(string reviewName) { ReviewConfiguration reviewFromDb; using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving review from DB"); reviewFromDb = ctx.ReviewConfigurations.SingleOrDefault(r => r.Name == reviewName); Assert.IsNotNull(reviewFromDb, "The review with name '{0}' could not be found in the DB!", reviewName); } _browser.Visit("/Review/Provide/" + reviewFromDb.Id); }
public void ThenTheFeedbackIsSavedWithForEachPeerForEachCategory(int rating) { using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving review from DB"); var reviewFromDb = ctx.ReviewConfigurations.Include("Feedback").Single(); var feedback = reviewFromDb.ReviewRounds.Last().Feedback.Single(); foreach (var assessment in feedback.Assessments) { Assert.AreEqual(rating, assessment.Rating); } } }
public void WhenAnAccountExistsForThatPeerSEmailAddress() { var peer = ScenarioContext.Current.Get <UserProfile>("peer"); using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Saving peer to DB"); ctx.UserProfiles.Add(new UserProfile { UserName = peer.UserName, EmailAddress = peer.EmailAddress }); ctx.SaveChanges(); } }
public void ThenMyNewReviewWasCreatedWithThoseCategories() { var review = ScenarioContext.Current.Get <ReviewConfiguration>(); using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving review from DB"); var reviewFromDb = ctx.ReviewConfigurations.Include("Categories").Single(); Assert.AreEqual(review.Name, reviewFromDb.Name); Assert.AreEqual(review.Categories.Count, reviewFromDb.Categories.Count); Assert.That(reviewFromDb.Categories, Is.EqualTo( review.Categories).AsCollection.Using(new CategoryComparer())); } }
public void ThenTheReviewIsNotSaved() { // works only when editing a review, for now // checking against the default review: see GivenIOwnAReview() var thisIsMe = ScenarioContext.Current.Get <UserProfile>(); using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving review from DB"); var reviewFromDb = ctx.ReviewConfigurations.Include("Categories").Include("Peers").Single(); Assert.AreEqual("Untitled Review", reviewFromDb.Name); Assert.AreEqual(thisIsMe.EmailAddress, reviewFromDb.Peers[0].EmailAddress); CollectionAssert.IsEmpty(reviewFromDb.Categories); } }
public void GivenIDonTHaveAnAccountAtTeamReview() { using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Retrieving user from DB"); if (!ctx.Database.Exists()) { Console.WriteLine("DB does not exist yet - no account exists"); } else { Assert.That(ctx.UserProfiles.ToList(), Has.Count.EqualTo(0)); } } }
private void GivenIOwnAReview(string reviewName) { var thisIsMe = ScenarioContext.Current.Get <UserProfile>(); var reviewConfiguration = new ReviewConfiguration { Name = reviewName, LengthOfReviewRoundInWeeks = 1 }; using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Writing review to DB"); reviewConfiguration.Peers.Add(ctx.UserProfiles.Find(thisIsMe.Id)); ctx.ReviewConfigurations.Add(reviewConfiguration); ctx.SaveChanges(); ScenarioContext.Current.Set(reviewConfiguration); } }
public void GivenIAmNotPartOfReview(string reviewName) { var reviewConfiguration = new ReviewConfiguration { Name = reviewName, LengthOfReviewRoundInWeeks = 1 }; using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Writing review to DB"); reviewConfiguration.Peers.Add(new UserProfile { EmailAddress = "*****@*****.**", UserName = "******" }); ctx.ReviewConfigurations.Add(reviewConfiguration); ctx.SaveChanges(); ScenarioContext.Current.Set(reviewConfiguration); } }
public void GivenIOwnAReviewWithTwoPeers() { var peers = new List <UserProfile>(); peers.Add(ScenarioContext.Current.Get <UserProfile>()); peers.Add(new UserProfile { EmailAddress = "Anton" + _emailDomain, UserName = "******" }); peers.Add(new UserProfile { EmailAddress = "Admin" + _emailDomain, UserName = "******" }); var reviewConfiguration = new ReviewConfiguration { Name = "NewReview", LengthOfReviewRoundInWeeks = 1, Peers = peers }; using (var ctx = new DelayedDatabaseContext()) { Console.WriteLine("Writing review to DB"); ctx.ReviewConfigurations.Add(reviewConfiguration); ctx.SaveChanges(); } ScenarioContext.Current.Set(reviewConfiguration); }