示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
 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));
     }
 }
示例#4
0
 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()));
     }
 }
示例#5
0
 public void WhenIFinishLogin()
 {
     _browser.FindId("Login").Click();
     using (var ctx = new DelayedDatabaseContext()) {
         Console.WriteLine("Retrieving user from DB");
         ScenarioContext.Current.Set(ctx.UserProfiles.Single());
     }
 }
示例#6
0
 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);
     }
 }
示例#7
0
        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));
            }
        }
示例#8
0
 public void GivenIRegisteredStandardly()
 {
     WhenIRegisterANewAccount();
     WhenIFillInMyEmailAddress("*****@*****.**");
     WhenIFinishRegistering();
     using (var ctx = new DelayedDatabaseContext()) {
         Console.WriteLine("Retrieving user from DB");
         ScenarioContext.Current.Set(ctx.UserProfiles.Single());
     }
 }
示例#9
0
 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);
     }
 }
示例#10
0
        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));
            }
        }
示例#11
0
        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));
            }
        }
示例#12
0
        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);
        }
示例#13
0
 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);
         }
     }
 }
示例#14
0
        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();
            }
        }
示例#15
0
        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()));
            }
        }
示例#16
0
        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);
            }
        }
示例#17
0
 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));
         }
     }
 }
示例#18
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);
            }
        }
示例#19
0
        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);
            }
        }
示例#20
0
        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);
        }