Ejemplo n.º 1
0
        public void UsersController_GetAll_SunnyDay()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                context.Users.Add(new HighFiveUser {
                    Email = "*****@*****.**"
                });
                context.SaveChanges();
            }

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

                var result = controller.GetAll();
                result.Should().BeOfType <OkObjectResult>();
                var okResult = result as OkObjectResult;
                var userList = okResult.Value as IList <UserViewModel>;
                userList.Should()
                .HaveCount(1)
                .And.ContainSingle(x => x.Email == "*****@*****.**");
            }
        }
Ejemplo n.º 2
0
        public void UsersController_Post_DuplicateUser()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                var organization = new Organization()
                {
                    Name = "Ariel Partners"
                };
                context.Organizations.Add(organization);
                context.Users.Add(new HighFiveUser()
                {
                    Email = "*****@*****.**", Organization = organization
                });
                context.SaveChanges();
            }
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo       = new HighFiveRepository(context, _repoLogger);
                UsersController    controller = new UsersController(repo, _controllerLogger);

                var duplicateUser = new UserViewModel()
                {
                    Email = "*****@*****.**", OrganizationName = "Ariel Partners"
                };
                var result = controller.Post(duplicateUser);
                result.Should().BeOfType <BadRequestObjectResult>();
                var badRequestResult = result as BadRequestObjectResult;
                AssertMessageProperty("Failed to add new user [email protected]", badRequestResult.Value);
            }
        }
        public void Repository_GetUserByEmail()
        {
            var options = CreateNewContextOptions();

            // add a user
            HighFiveUser highFiveUser = new HighFiveUser();

            highFiveUser.Organization      = new Organization();
            highFiveUser.Email             = "*****@*****.**";
            highFiveUser.Organization.Name = "Ariel Partners";

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

            highFiveUser = null;

            // make sure the user was added
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo = new HighFiveRepository(context, _repoLogger);
                highFiveUser = repo.GetUserByEmail("*****@*****.**");
                Assert.IsNotNull(highFiveUser);
            }
        }
Ejemplo n.º 4
0
        public void UsersController_Post_SunnyDay()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                var organization = new Organization()
                {
                    Name = "Ariel Partners"
                };
                context.Organizations.Add(organization);
                context.Users.Add(new HighFiveUser()
                {
                    Email = "*****@*****.**", Organization = organization
                });
                context.SaveChanges();
            }

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

                var newUser = new UserViewModel()
                {
                    Email = "*****@*****.**", OrganizationName = "Ariel Partners"
                };
                var result = controller.Post(newUser);
                result.Should().BeOfType <CreatedResult>();
                var createdResult = result as CreatedResult;
                var user          = createdResult.Value as UserViewModel;
                user.Email.Should().Be("*****@*****.**");
            }
        }
        public void OrganizationsControllers_GetAll_SunnyDay()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                context.Organizations.Add(new Organization {
                    Name = "Ariel Partners", Values = new List <CorporateValue> {
                        new CorporateValue {
                            Name = "Test Name", Description = "Testing Description"
                        }
                    }
                });
                context.SaveChanges();

                var repo       = new HighFiveRepository(context, _repoLogger);
                var controller = new OrganizationsController(repo, _controllerLogger);

                var result = controller.GetAll();
                result.Should().BeOfType <OkObjectResult>();
                var okResult = result as OkObjectResult;
                var orgList  = okResult.Value as IList <OrganizationViewModel>;
                orgList.Should().HaveCount(1).And.ContainSingle(x => x.Name == "Ariel Partners");
            }
        }
        public void When_I_view_my_point_balance()
        {
            using (var context = new HighFiveContext(_config, _options))
            {
                var repo       = new HighFiveRepository(context, _repoLogger);
                var controller = new UsersController(repo, _controllerLogger);

                var result = controller.GetByEmail("*****@*****.**");
                result.Should().BeOfType <OkObjectResult>();
                var okResult = result as OkObjectResult;
                _userViewModelOutput = okResult.Value as UserViewModel;

                IEnumerable <Recognition> recognitionList = new List <Recognition>();
                recognitionList = repo.GetAllRecognitions();

                _recognition = null;

                foreach (Recognition rec in recognitionList)
                {
                    if (rec.Receiver.Email == "*****@*****.**")
                    {
                        _recognition = rec;
                    }
                }

                _userViewModelOutput.PointBalance = _recognition.Points;
            }
        }
        public void OrganizationsControllers_Put_SunnyDay()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                var repo       = new HighFiveRepository(context, _repoLogger);
                var controller = new OrganizationsController(repo, _controllerLogger);
                //Adding an Organization
                controller.Post(new OrganizationViewModel {
                    Name = "Macys", Values = new List <CorporateValue> {
                        new CorporateValue {
                            Name = "Test Name", Description = "Testing Description"
                        }
                    }
                });

                var returnObject = controller.Put("Macys", new OrganizationViewModel {
                    Name = "Macys " + DateTime.Now.TimeOfDay, Values = new List <CorporateValue> {
                        new CorporateValue {
                            Name = "Test Name" + DateTime.Now.TimeOfDay, Description = "Testing Description" + DateTime.Now.TimeOfDay
                        }
                    }
                });
                returnObject.Result.Should().BeOfType <OkObjectResult>();
                var okObjectResult = returnObject.Result as OkObjectResult;
                AssertMessageProperty("Organization Macys updated successfully", okObjectResult.Value);
            }
        }
        public void OrganizationsControllers_Post_DuplicateOrganization()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                var repo       = new HighFiveRepository(context, _repoLogger);
                var controller = new OrganizationsController(repo, _controllerLogger);
                //Adding an Organization
                var returnObject = controller.Post(new OrganizationViewModel {
                    Name = "Macys", Values = new List <CorporateValue> {
                        new CorporateValue {
                            Name = "Test Name1", Description = "Testing Description1"
                        }
                    }
                });

                //Create an Organization with the same name
                returnObject = controller.Post(new OrganizationViewModel {
                    Name = "Macys", Values = new List <CorporateValue> {
                        new CorporateValue {
                            Name = "Test Name2", Description = "Testing Description2"
                        }
                    }
                });
                returnObject.Result.Should().BeOfType <BadRequestObjectResult>();
                var badRequestResult = returnObject.Result as BadRequestObjectResult;
                AssertMessageProperty("Organization Macys already exists in the database", badRequestResult.Value);
            }
        }
        public void OrganizationsControllers_Post_InvalidModel()
        {
            var options = CreateNewContextOptions();

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

                controller.ViewData.ModelState.Clear();

                var noname = new OrganizationViewModel();
                controller.ViewData.ModelState.AddModelError("Name", "The Name field is required.");

                controller.ViewData.ModelState.Should().HaveCount(1);
                controller.ViewData.ModelState["Name"].Errors.Should().HaveCount(1);
                controller.ViewData.ModelState["Name"].Errors[0].ErrorMessage.Should().Be("The Name field is required.");

                var org = controller.Post(noname);
                org.Result.Should().BeOfType <BadRequestObjectResult>();
                var badRequestResult = org.Result as BadRequestObjectResult;
                var errLst           = badRequestResult.Value as SerializableError;
                var errMsg           = ((string[])errLst["Name"]).Aggregate(string.Empty, (current, errVal) => current + errVal);
                Assert.AreEqual("The Name field is required.", errMsg);
            }
        }
Ejemplo n.º 10
0
        public void UsersController_GetByEmail_SunnyDay()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                context.Users.Add(new HighFiveUser {
                    Email = "*****@*****.**"
                });
                context.SaveChanges();
            }

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

                var result = controller.GetByEmail("*****@*****.**");
                result.Should().BeOfType <OkObjectResult>();
                var okResult = result as OkObjectResult;
                var user     = okResult.Value as UserViewModel;
                user.Email.Should().Be("*****@*****.**");

                result = controller.GetByEmail("*****@*****.**");
                result.Should().BeOfType <NotFoundObjectResult>();
                var notFoundResult = result as NotFoundObjectResult;
                AssertMessageProperty("User [email protected] not found", notFoundResult.Value);
            }
        }
        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_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 Repository_IsConnected()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                var repo = new HighFiveRepository(context, _repoLogger);
                repo.IsConnected();
            }
        }
        public void Repository_AddCorporateValue()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                var repo = new HighFiveRepository(context, _repoLogger);
                repo.AddCorporateValue(new CorporateValue {
                    Name = "Corporate Value1"
                });
            }
        }
Ejemplo n.º 15
0
        public void UsersController_GetAll_NoContent()
        {
            var options = CreateNewContextOptions();

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

                var result = controller.GetAll();
                result.Should().BeOfType <NoContentResult>();
            }
        }
        public void OrganizationsControllers_Delete_NotFound()
        {
            var options = CreateNewContextOptions();

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

                var result = controller.Delete("Macys");
                result.Result.Should().BeOfType <NotFoundObjectResult>();
                var badRequestResult = result.Result as NotFoundObjectResult;
                AssertMessageProperty("Unable to find organization Macys", badRequestResult.Value);
            }
        }
        public void Then_the_following_user_should_exist(Table table)
        {
            HighFiveUser user = table.CreateInstance <HighFiveUser>();

            HighFiveRepository repo       = new HighFiveRepository(_context, _repoLogger);
            UsersController    controller = new UsersController(repo, _usersControllerLogger);

            var result = controller.GetByEmail(user.Email);

            result.Should().BeOfType <OkObjectResult>();
            var okResult      = result as OkObjectResult;
            var userViewModel = okResult.Value as UserViewModel;

            userViewModel.Email.Should().Be(user.Email);
        }
Ejemplo n.º 18
0
        public void Given_A_user_with_email_EMAIL_does_not_have_an_account(string email)
        {
            //empty new context
            var options = CreateNewContextOptions();
            var context = new HighFiveContext(_config, options);

            context.Organizations.Add(new Organization {
                Name = "Ariel Partners", Values = new List <CorporateValue> {
                    new CorporateValue {
                        Name = "Test Name", Description = "Testing Description"
                    }
                }
            });
            context.SaveChanges();
            _reposCreateUser = new HighFiveRepository(context, _repoLogger);
        }
        public void Given_the_following_user_does_not_exist(Table table)
        {
            var nonExistingUser = new HighFiveUser {
                Email = "*****@*****.**"
            };

            HighFiveRepository repo       = new HighFiveRepository(_context, _repoLogger);
            UsersController    controller = new UsersController(repo, _usersControllerLogger);

            var result = controller.GetByEmail(nonExistingUser.Email);

            result.Should().BeOfType <NotFoundObjectResult>();
            var notFoundResult = result as NotFoundObjectResult;

            AssertMessageProperty("User " + nonExistingUser.Email + " not found", notFoundResult.Value);
        }
        public void When_I_view_the_home_page()
        {
            using (var context = new HighFiveContext(_config, _options))
            {
                var repo = new HighFiveRepository(context, _repoLogger);
                //var repo = new Mock<IHighFiveRepository>();
                //repo.Setup(r => r.GetAllRecognitions()).Returns(_recognitions);
                var controller = new RecognitionsController(repo, _controllerLogger);

                var result = controller.GetAll();
                result.Should().BeOfType <OkObjectResult>();
                var okResult = result as OkObjectResult;
                //var lst = okResult.Value as IEnumerable<RecognitionViewModel>;
                //_recognitionOutputList = lst.OrderByDescending(x => x.DateCreated).ToList();
                _recognitionOutputList = okResult.Value as IList <RecognitionViewModel>;
            }
        }
        public void Repository_GetAllUsers()
        {
            var options = CreateNewContextOptions();

            // user count should be zero to start
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository         repo      = new HighFiveRepository(context, _repoLogger);
                IEnumerable <HighFiveUser> userList  = repo.GetAllUsers();
                List <HighFiveUser>        userList2 = (List <HighFiveUser>)userList;
                userList2.Should().BeEmpty();
            }

            // add a user
            using (var context = new HighFiveContext(_config, options))
            {
                context.Users.Add(new HighFiveUser {
                    Email = "*****@*****.**"
                });
                context.SaveChanges();
            }

            // test only one user was added and the email address is the same as added
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository         repo      = new HighFiveRepository(context, _repoLogger);
                IEnumerable <HighFiveUser> userList  = repo.GetAllUsers();
                List <HighFiveUser>        userList2 = (List <HighFiveUser>)userList;

                //Assert.AreEqual(1, userList2.Count);
                userList2.Should().HaveCount(1);

                // make sure the email address is the same as added. TODO, make this a lambda expression
                int userCount = 0;
                foreach (HighFiveUser highFiveUser in userList2)
                {
                    if (highFiveUser.Email == "*****@*****.**")
                    {
                        userCount++;
                    }
                }

                Assert.AreEqual(1, userCount);
            }
        }
Ejemplo n.º 22
0
        public void UsersController_Post_UnknownOrganization()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo       = new HighFiveRepository(context, _repoLogger);
                UsersController    controller = new UsersController(repo, _controllerLogger);
                var unknownOrgUser            = new UserViewModel()
                {
                    Email = "*****@*****.**", OrganizationName = "Bad Guys"
                };
                var result = controller.Post(unknownOrgUser);
                result.Should().BeOfType <NotFoundObjectResult>();
                var notFoundResult = result as NotFoundObjectResult;
                AssertMessageProperty("Unable to find organization Bad Guys", notFoundResult.Value);
            }
        }
        public void OrganizationsControllers_GetOrganizationByName_SunnyDay()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                context.Organizations.Add(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 "
                        }
                    }
                });
                context.SaveChanges();

                var repo       = new HighFiveRepository(context, _repoLogger);
                var controller = new OrganizationsController(repo, _controllerLogger);

                var result = controller.GetOrganizationByName("Ariel Partners");
                result.Should().BeOfType <OkObjectResult>();
                var okResult = result as OkObjectResult;
                var org      = okResult.Value as OrganizationViewModel;
                org.Name.Should().Be("Ariel Partners");

                result = controller.GetOrganizationByName("Yeehaa");
                result.Should().BeOfType <NotFoundObjectResult>();
                var notFoundResult = result as NotFoundObjectResult;
                AssertMessageProperty("Unable to find organization Yeehaa", notFoundResult.Value);
            }
        }
Ejemplo n.º 24
0
        public void Given_A_user_with_username_EMAIL_and_password_PASSWORD_exists(string email, string password)
        {
            var options = CreateNewContextOptions();
            var context = new HighFiveContext(_config, options);

            context.Organizations.Add(new Organization {
                Name = "Ariel Partners", Values = new List <CorporateValue> {
                    new CorporateValue {
                        Name = "Test Name", Description = "Testing Description"
                    }
                }
            });
            context.SaveChanges();
            _reposDeleteUser = new HighFiveRepository(context, _repoLogger);

            var signInManager = new Mock <IWrapSignInManager <HighFiveUser> >().Object;
            var controller    = new AuthController(signInManager, _reposDeleteUser, _controllerLogger);
            // Following method needs to be implemented before SelfRegister can work
            // or wrap UserManager and add to services
            //var result = controller.SelfRegister(string username, string password, string organization)
        }
        public void OrganizationsControllers_Put_NotFound()
        {
            var options = CreateNewContextOptions();

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

                var returnObject = controller.Put("Macys", new OrganizationViewModel {
                    Name = "Macys", Values = new List <CorporateValue> {
                        new CorporateValue {
                            Name = "Test Name1", Description = "Testing Description1"
                        }
                    }
                });
                returnObject.Result.Should().BeOfType <NotFoundObjectResult>();
                var notFoundObjectResult = returnObject.Result as NotFoundObjectResult;
                AssertMessageProperty("Unable to find organization Macys", notFoundObjectResult.Value);
            }
        }
        public void Repository_UpdateUser()
        {
            var options = CreateNewContextOptions();

            // add the user
            HighFiveUser highFiveUser = new HighFiveUser();

            highFiveUser.Organization      = new Organization();
            highFiveUser.Email             = "*****@*****.**";
            highFiveUser.Organization.Name = "Ariel Partners";

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

            highFiveUser = null;

            // update the user's email address
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo = new HighFiveRepository(context, _repoLogger);
                highFiveUser       = repo.GetUserByEmail("*****@*****.**");
                highFiveUser.Email = "*****@*****.**";
                context.Update(highFiveUser);
                context.SaveChanges();
            }

            //TODO - add a test too make sure original email [email protected] is not on file

            // read the user and make sure the email was updated
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo = new HighFiveRepository(context, _repoLogger);
                highFiveUser = null;
                highFiveUser = repo.GetUserByEmail("*****@*****.**");
                Assert.AreEqual("*****@*****.**", highFiveUser.Email);
            }
        }
Ejemplo n.º 27
0
        public void UsersController_Delete_SunnyDay()
        {
            var options = CreateNewContextOptions();

            using (var context = new HighFiveContext(_config, options))
            {
                var organization = new Organization()
                {
                    Name = "Ariel Partners"
                };
                context.Organizations.Add(organization);
                context.Users.Add(new HighFiveUser()
                {
                    Email = "*****@*****.**", Organization = organization
                });
                context.SaveChanges();
            }

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

                var result = controller.Delete("*****@*****.**");
                result.Should().BeOfType <NotFoundObjectResult>();
                var notFoundResult = result as NotFoundObjectResult;
                AssertMessageProperty("User [email protected] not found", notFoundResult.Value);
                context.Users.Should().HaveCount(1);

                result = controller.Delete("*****@*****.**");
                result.Should().BeOfType <OkObjectResult>();

                context.Users.Should().BeEmpty();

                result = controller.Delete("*****@*****.**");
                result.Should().BeOfType <NotFoundObjectResult>();
                notFoundResult = result as NotFoundObjectResult;
                AssertMessageProperty("User [email protected] not found", notFoundResult.Value);
            }
        }
        public void Repository_AddUser()
        {
            var options = CreateNewContextOptions();

            HighFiveUser highFiveUser;

            // make sure this user is not on file
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo = new HighFiveRepository(context, _repoLogger);
                highFiveUser = repo.GetUserByEmail("*****@*****.**");
                //Assert.IsNull(highFiveUser);
                highFiveUser.Should().BeNull();
            }

            // add the user
            highFiveUser = new HighFiveUser();
            highFiveUser.Organization      = new Organization();
            highFiveUser.Email             = "*****@*****.**";
            highFiveUser.Organization.Name = "Ariel Partners";

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

            highFiveUser = null;

            // get the user by email
            using (var context = new HighFiveContext(_config, options))
            {
                HighFiveRepository repo = new HighFiveRepository(context, _repoLogger);
                highFiveUser = repo.GetUserByEmail("*****@*****.**");
                Assert.IsNotNull(highFiveUser);
                highFiveUser.Email.Should().Be("*****@*****.**");
                Assert.AreEqual("Ariel Partners", highFiveUser.Organization.Name);
            }
        }
        public void OrganizationsControllers_Post_SunnyDay()
        {
            var options = CreateNewContextOptions();

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

                var org = controller.Post(new OrganizationViewModel {
                    Name = "Macys", Values = new List <CorporateValue> {
                        new CorporateValue {
                            Name = "Test Name1", Description = "Testing Description1"
                        }
                    }
                });
                org.Result.Should().BeOfType <CreatedResult>();
                var createdResult  = org.Result as CreatedResult;
                var organizationVm = createdResult.Value as OrganizationViewModel;
                organizationVm.Name.Should().Be("Macys");
            }
        }
        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);
            }
        }