Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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);
        }