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

            // add the organization
            Organization organization = new Organization();

            organization.Name = "Ariel Partners";

            using (var context = new HighFiveContext(_config, options))
            {
                context.Organizations.Add(organization);
                context.SaveChanges();
            }

            organization = null;

            // make sure the organization was added
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo = new HighFiveRepository(context, _repoLogger);
                organization = repo.GetOrganizationByName("Ariel Partners");
                Assert.IsNotNull(organization);
            }
        }
        public void Repository_AddOrganization()
        {
            var options = CreateNewContextOptions();

            Organization organization;

            // make sure this user is not on file
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo = new HighFiveRepository(context, _repoLogger);
                organization = repo.GetOrganizationByName("Macys");
                Assert.IsNull(organization);
            }

            // add the organization
            organization      = new Organization();
            organization.Name = "Macys";
            Guid organizationId;

            using (var context = new HighFiveContext(_config, options))
            {
                var abc = context.Organizations.Add(organization);
                context.SaveChanges();
                organizationId = organization.Id;
            }

            organization = null;

            // get the user by email
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo = new HighFiveRepository(context, _repoLogger);
                organization = repo.GetOrganizationByName("Macys");
                Assert.IsNotNull(organization);
                Assert.AreEqual("Macys", organization.Name);
                Assert.AreEqual(organizationId, organization.Id);
            }
        }
        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();
            }
        }