public void Repository_GetWeekMetrics()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                var repo = new HighFiveRepository(context, _repoLogger);

                var corpVal1 = new CorporateValue {
                    Name = "Corporate Value1"
                };
                var corpVal2 = new CorporateValue {
                    Name = "Corporate Value2"
                };
                var corpVal3 = new CorporateValue {
                    Name = "Corporate Value3"
                };

                ICollection <CorporateValue> corpVals = new List <CorporateValue>();
                corpVals.Add(corpVal1);
                corpVals.Add(corpVal2);
                corpVals.Add(corpVal3);

                repo.AddCorporateValue(corpVal1);
                repo.AddCorporateValue(corpVal2);
                repo.AddCorporateValue(corpVal3);
                repo.SaveChanges();

                Organization org = new Organization {
                    Name = "TestOrg", Values = corpVals
                };

                repo.AddOrganization(org);

                //DateCreated will be within a week since it is set to now
                repo.AddRecognition(new Recognition {
                    Value = repo.GetCorporateValueByName("Corporate Value1"), Organization = org, Points = 1
                });
                repo.AddRecognition(new Recognition {
                    Value = repo.GetCorporateValueByName("Corporate Value1"), Organization = org, Points = 1
                });
                repo.AddRecognition(new Recognition {
                    Value = repo.GetCorporateValueByName("Corporate Value2"), Organization = org, Points = 3
                });
                repo.AddRecognition(new Recognition {
                    Value = repo.GetCorporateValueByName("Corporate Value3"), Organization = org, Points = 5
                });

                repo.SaveChanges();
                var weekMetrics = repo.GetMetrics(org.Name, 7);
                weekMetrics.ToList().Count.Should().Equals(3);
                var met1 = weekMetrics.FirstOrDefault(m => m.CorporateValue == "Corporate Value1");
                met1.Points.Should().Equals(2);
                var met2 = weekMetrics.FirstOrDefault(m => m.CorporateValue == "Corporate Value2");
                met1.Points.Should().Equals(2);
                var met3 = weekMetrics.FirstOrDefault(m => m.CorporateValue == "Corporate Value3");
                met1.Points.Should().Equals(2);
            }
        }
        public void Given_the_following_recognitions_exist_in_the_system(Table table)
        {
            var recognitionsLst = table.CreateSet <RecognitionViewModel>();

            // add recognitions to the in memory repository
            using (var context = new HighFiveContext(_config, _options))
            {
                //Add Organization
                var org = new Organization
                {
                    Name   = "Ariel Partners",
                    Values = new List <CorporateValue>
                    {
                        new CorporateValue {
                            Name = "Commitment", Description = "Committed to the long term success and happiness of our customers, our people, and our partners"
                        },
                        new CorporateValue {
                            Name = "Courage", Description = "To take on difficult challenges, to accept new ideas, to accept incremental failure"
                        },
                        new CorporateValue {
                            Name = "Excellence", Description = "Always strive to exceed expectations and continuously improve"
                        },
                        new CorporateValue {
                            Name = "Integrity", Description = "Always act honestly, ethically, and do the right thing even when it hurts"
                        },
                        new CorporateValue {
                            Name = "Honesty", Description = "Always act honestly, ethically, and do the right thing even when it hurts"
                        },
                        new CorporateValue {
                            Name = "Vigilance", Description = "Always act honestly, ethically, and do the right thing even when it hurts"
                        },
                        new CorporateValue {
                            Name = "Respect", Description = "Always act honestly, ethically, and do the right thing even when it hurts"
                        }
                    }
                };
                context.Organizations.Add(org);
                context.SaveChanges();
                org = context.Organizations.FirstOrDefault();
                //Add Users
                var testUsersLst = new List <HighFiveUser>
                {
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "joe", LastName = "", Organization = org
                    },
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "suresh", LastName = "", Organization = org
                    },
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "matthew", LastName = "", Organization = org
                    },
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "sue", LastName = "", Organization = org
                    },
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "dave", LastName = "", Organization = org
                    },
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "nikhil", LastName = "", Organization = org
                    },
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "jose", LastName = "", Organization = org
                    },
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "tom", LastName = "", Organization = org
                    },
                    new HighFiveUser {
                        UserName = "******", Email = "*****@*****.**", FirstName = "john", LastName = "", Organization = org
                    }
                };
                foreach (var usr in testUsersLst)
                {
                    context.Users.Add(usr);
                }
                context.SaveChanges();
                //Create the Recognitions
                var repo = new HighFiveRepository(context, _repoLogger);
                // for each item in the table, create a recognition
                foreach (RecognitionViewModel recViewModel in recognitionsLst)
                {
                    var obj = Mapper.Map <Recognition>(recViewModel);
                    obj.Sender       = repo.GetUserByEmail(recViewModel.SenderEmail);
                    obj.Receiver     = repo.GetUserByEmail(recViewModel.ReceiverEmail);
                    obj.Organization = repo.GetOrganizationByName(recViewModel.OrganizationName);
                    obj.Value        = repo.GetCorporateValueByName(recViewModel.CorporateValueName);
                    _recognitions.Add(obj);
                }
                context.Recognitions.AddRange(_recognitions);
                context.SaveChangesAsync();
            }
        }