public void TestCreateWorkgroupPostRedirectsWhenValid()
        {
            #region Arrange
            Controller.ControllerContext.HttpContext = new MockHttpContext(0, new[] { "" }, "3");
            SetupDataForWorkgroupActions1();
            new FakeOrganizationDescendants(3, OrganizationDescendantRepository);
            var workgroup = CreateValidEntities.Workgroup(1);
            workgroup.PrimaryOrganization = OrganizationRepository.Queryable.Single(a => a.Id == "7");
            workgroup.SetIdTo(99);
            WorkgroupService.Expect(a => a.CreateWorkgroup(workgroup, null)).Return(workgroup).Repeat.Any();
            SecurityService.Expect(a => a.HasWorkgroupOrOrganizationAccess(Arg <Workgroup> .Is.Anything, Arg <Organization> .Is.Anything, out Arg <string> .Out(null).Dummy)).Return(true);
            #endregion Arrange

            #region Act
            var result = Controller.CreateWorkgroup(workgroup)
                         .AssertActionRedirect()
                         .ToAction <WizardController>(a => a.AddSubOrganizations(99));
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(99, result.RouteValues["id"]);
            Assert.AreEqual(1, Controller.ViewBag.StepNumber);

            WorkgroupService.AssertWasCalled(a => a.CreateWorkgroup(Arg <Workgroup> .Is.Anything, Arg <string[]> .Is.Anything));
            var args = WorkgroupService.GetArgumentsForCallsMadeOn(a => a.CreateWorkgroup(Arg <Workgroup> .Is.Anything, Arg <string[]> .Is.Anything))[0];
            Assert.AreEqual("Name1", ((Workgroup)args[0]).Name);
            Assert.IsNull(args[1]);
            Assert.AreEqual("Name1 workgroup was created", Controller.Message);
            #endregion Assert
        }
        public void TestEditWorkgroupVendorPostReturnsViewWhenNotValid()
        {
            #region Arrange
            new FakeVendors(3, VendorRepository);
            var workgroupVendors = new List <WorkgroupVendor>();
            workgroupVendors.Add(CreateValidEntities.WorkgroupVendor(5));
            workgroupVendors[0].VendorId = null;
            workgroupVendors[0].VendorAddressTypeCode = null;
            new FakeWorkgroupVendors(0, WorkgroupVendorRepository, workgroupVendors);

            var workgroupVendor = CreateValidEntities.WorkgroupVendor(9);
            workgroupVendor.VendorId = null;
            workgroupVendor.VendorAddressTypeCode = null;
            workgroupVendor.Name = null;
            WorkgroupService.Expect(a => a.TransferValues(Arg <WorkgroupVendor> .Is.Anything, ref Arg <WorkgroupVendor> .Ref(Is.Anything(), workgroupVendor).Dummy));
            #endregion Arrange

            #region Act
            var result = Controller.EditWorkgroupVendor(0, 1, workgroupVendor)
                         .AssertViewRendered()
                         .WithViewData <WorkgroupVendorViewModel>();
            #endregion Act

            #region Assert
            Controller.ModelState.AssertErrorsAre("The Name field is required.");
            Assert.IsNotNull(result);
            Assert.AreEqual("Line19", result.WorkgroupVendor.Line1);
            #endregion Assert
        }
Exemplo n.º 3
0
        public void TestIndexReturnsView1()
        {
            #region Arrange
            Controller.ControllerContext.HttpContext = new MockHttpContext(0, new[] { "" }, "2");
            SetupDataForWorkgroupActions1();
            new FakeAdminWorkgroups(3, AdminWorkgroupRepository);
            WorkgroupService.Expect(a => a.LoadAdminWorkgroups(false)).Return(new Workgroup[0]);
            #endregion Arrange

            #region Act
            var result = Controller.Index()
                         .AssertViewRendered()
                         .WithViewData <WorkgroupIndexModel>();
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.WorkGroups.Count());
            Assert.IsFalse(result.ShowAll);

            //Assert.AreEqual("Name4", result[0].Name);
            //Assert.AreEqual("Name1", result[0].Organizations.ElementAt(0).Name);
            //Assert.AreEqual("Name4", result[0].Organizations.ElementAt(1).Name);

            //Assert.AreEqual("Name5", result[1].Name);
            //Assert.AreEqual("Name1", result[1].Organizations.ElementAt(0).Name);
            //Assert.AreEqual("Name5", result[1].Organizations.ElementAt(1).Name);

            //Assert.AreEqual("Name6", result[2].Name);
            //Assert.AreEqual("Name1", result[2].Organizations.ElementAt(0).Name);
            //Assert.AreEqual("Name6", result[2].Organizations.ElementAt(1).Name);
            #endregion Assert
        }
Exemplo n.º 4
0
        public void TestCreateVendorPostWithInvalidValueReturnsView4()
        {
            #region Arrange
            SetupDataForVendors3();
            var vendorToCreate = CreateValidEntities.WorkgroupVendor(9);
            vendorToCreate.VendorId = null;
            vendorToCreate.City     = null;
            WorkgroupService.Expect(a => a.TransferValues(Arg <WorkgroupVendor> .Is.Anything, ref Arg <WorkgroupVendor> .Ref(Is.Anything(), vendorToCreate).Dummy));
            #endregion Arrange

            #region Act
            var result = Controller.CreateVendor(3, vendorToCreate, true)
                         .AssertViewRendered()
                         .WithViewData <WorkgroupVendorViewModel>();
            #endregion Act

            #region Assert
            WorkgroupVendorRepository.AssertWasNotCalled(a => a.EnsurePersistent(Arg <WorkgroupVendor> .Is.Anything));
            Controller.ModelState.AssertErrorsAre("The City field is required.");

            Assert.IsNotNull(result);
            Assert.AreEqual(true, result.NewVendor);
            Assert.AreEqual(null, result.VendorAddress);
            Assert.AreEqual(null, result.WorkgroupVendor.City);
            Assert.AreEqual("Line19", result.WorkgroupVendor.Line1);
            Assert.AreEqual(null, result.Vendor);
            #endregion Assert
        }
Exemplo n.º 5
0
        public void TestCreateVendorPostWhenValidRedirectsAndSaves4()
        {
            #region Arrange
            SetupDataForVendors2();
            var vendorToCreate = CreateValidEntities.WorkgroupVendor(9);
            vendorToCreate.VendorId = null;
            WorkgroupService.Expect(a => a.TransferValues(Arg <WorkgroupVendor> .Is.Anything, ref Arg <WorkgroupVendor> .Ref(Is.Anything(), vendorToCreate).Dummy));
            #endregion Arrange

            #region Act
            var result = Controller.CreateVendor(3, vendorToCreate, true)
                         .AssertActionRedirect()
                         .ToAction <WorkgroupController>(a => a.VendorList(3));
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.RouteValues["id"]);
            Assert.AreEqual("WorkgroupVendor Created Successfully", Controller.Message);

            WorkgroupVendorRepository.AssertWasCalled(a => a.EnsurePersistent(Arg <WorkgroupVendor> .Is.Anything));
            var args = (WorkgroupVendor)WorkgroupVendorRepository.GetArgumentsForCallsMadeOn(a => a.EnsurePersistent(Arg <WorkgroupVendor> .Is.Anything))[0][0];
            Assert.IsNotNull(args);
            Assert.AreEqual(null, args.VendorId);
            Assert.AreEqual("tc9", args.VendorAddressTypeCode);
            Assert.AreEqual("Name9", args.Name);
            #endregion Assert
        }
        public void TestGetChildWorkgroupIdsReturnsJsonNetResult6()
        {
            #region Arrange
            var workgroups = new List <Workgroup>();
            for (int i = 0; i < 5; i++)
            {
                workgroups.Add(CreateValidEntities.Workgroup(i + 1));
                workgroups[i].IsActive       = true;
                workgroups[i].Administrative = true;
            }

            workgroups[1].Administrative = false;
            workgroups[2].IsActive       = false;
            workgroups[3].Administrative = false;
            workgroups[3].IsActive       = false;

            new FakeWorkgroups(0, RepositoryFactory.WorkgroupRepository, workgroups);
            WorkgroupService.Expect(a => a.GetChildWorkgroups(5)).Return(new List <int>()).Repeat.Any();
            #endregion Arrange

            #region Act
            var result = Controller.GetChildWorkgroupIds(5)
                         .AssertResultIs <JsonNetResult>();
            #endregion Act

            #region Assert
            dynamic data = JObject.FromObject(result.Data);
            Assert.IsTrue(data.success.Value);
            Assert.AreEqual("None", data.message.Value);
            WorkgroupService.AssertWasCalled(a => a.GetChildWorkgroups(5));
            #endregion Assert
        }
        public void TestEditWorkgroupVendorPostRedirectsWhenValid()
        {
            #region Arrange
            new FakeVendors(3, VendorRepository);
            var workgroup = CreateValidEntities.Workgroup(15);
            workgroup.SetIdTo(15);

            var workgroupVendors = new List <WorkgroupVendor>();
            workgroupVendors.Add(CreateValidEntities.WorkgroupVendor(5));
            workgroupVendors[0].VendorId = null;
            workgroupVendors[0].VendorAddressTypeCode = null;
            workgroupVendors[0].Workgroup             = workgroup;
            new FakeWorkgroupVendors(0, WorkgroupVendorRepository, workgroupVendors);

            var workgroupVendor = CreateValidEntities.WorkgroupVendor(9);
            workgroupVendor.Workgroup.SetIdTo(15);
            workgroupVendor.VendorId = null;
            workgroupVendor.VendorAddressTypeCode = null;
            workgroupVendor.Name = "Changed";
            WorkgroupService.Expect(a => a.TransferValues(Arg <WorkgroupVendor> .Is.Anything, ref Arg <WorkgroupVendor> .Ref(Is.Anything(), workgroupVendor).Dummy));
            #endregion Arrange

            #region Act
            var result = Controller.EditWorkgroupVendor(15, 1, workgroupVendor)
                         .AssertActionRedirect()
                         .ToAction <WorkgroupController>(a => a.VendorList(15));
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(15, result.RouteValues["id"]);

            Assert.AreEqual("WorkgroupVendor Edited Successfully", Controller.Message);

            WorkgroupVendorRepository.AssertWasCalled(a => a.EnsurePersistent(Arg <WorkgroupVendor> .Is.Anything), x => x.Repeat.Times(2));
            var oldArgs = (WorkgroupVendor)WorkgroupVendorRepository.GetArgumentsForCallsMadeOn(a => a.EnsurePersistent(Arg <WorkgroupVendor> .Is.Anything))[0][0];
            var newArgs = (WorkgroupVendor)WorkgroupVendorRepository.GetArgumentsForCallsMadeOn(a => a.EnsurePersistent(Arg <WorkgroupVendor> .Is.Anything))[1][0];

            Assert.IsNotNull(oldArgs);
            Assert.AreEqual("Name5", oldArgs.Name);
            Assert.IsFalse(oldArgs.IsActive);

            Assert.IsNotNull(newArgs);
            Assert.AreEqual("Changed", newArgs.Name);
            Assert.IsTrue(newArgs.IsActive);
            #endregion Assert
        }
Exemplo n.º 8
0
        public void TestCreateVendorPostWithInvalidValueReturnsView1()
        {
            #region Arrange
            SetupDataForVendors3();
            var vendorToCreate = CreateValidEntities.WorkgroupVendor(9);
            vendorToCreate.Line1 = null;
            WorkgroupService.Expect(a => a.TransferValues(Arg <WorkgroupVendor> .Is.Anything, ref Arg <WorkgroupVendor> .Ref(Is.Anything(), vendorToCreate).Dummy));
            #endregion Arrange

            #region Act
            Controller.CreateVendor(3, vendorToCreate, false)
            .AssertViewRendered()
            .WithViewData <WorkgroupVendorViewModel>();
            #endregion Act

            #region Assert
            WorkgroupVendorRepository.AssertWasNotCalled(a => a.EnsurePersistent(Arg <WorkgroupVendor> .Is.Anything));
            Controller.ModelState.AssertErrorsAre("The Line1 field is required.");
            #endregion Assert
        }
Exemplo n.º 9
0
        public void TestIndexReturnsView2()
        {
            #region Arrange
            Controller.ControllerContext.HttpContext = new MockHttpContext(0, new[] { "" }, "1");
            SetupDataForWorkgroupActions1();
            new FakeAdminWorkgroups(3, AdminWorkgroupRepository);
            WorkgroupService.Expect(a => a.LoadAdminWorkgroups(false)).Return(new Workgroup[0]);
            #endregion Arrange

            #region Act
            var result = Controller.Index()
                         .AssertViewRendered()
                         .WithViewData <WorkgroupIndexModel>();
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.WorkGroups.Count());
            #endregion Assert
        }
Exemplo n.º 10
0
        public void TestAddPeoplePostRedirectsToPeople1()
        {
            #region Arrange
            SetupDataForPeopleList();
            string message   = "Fake Message";
            int    failCount = 2;
            SecurityService.Expect(a => a.HasWorkgroupOrOrganizationAccess(Arg <Workgroup> .Is.Anything, Arg <Organization> .Is.Anything, out Arg <string> .Out(message).Dummy)).Return(true);
            WorkgroupService.Expect(a => a.TryToAddPeople(
                                        Arg <int> .Is.Anything,
                                        Arg <Role> .Is.Anything,
                                        Arg <Workgroup> .Is.Anything,
                                        Arg <int> .Is.Anything,
                                        Arg <string> .Is.Anything,
                                        ref Arg <int> .Ref(Is.Anything(), failCount).Dummy,
                                        ref Arg <int> .Ref(Is.Anything(), failCount).Dummy,
                                        Arg <List <KeyValuePair <string, string> > > .Is.Anything)).Return(7).Repeat.Any();

            var ldapUser = new DirectoryUser();
            ldapUser.FirstName    = "Me";
            ldapUser.LastName     = "You";
            ldapUser.LoginId      = "Logger";
            ldapUser.EmailAddress = "*****@*****.**";
            SearchService.Expect(a => a.FindUser("Me")).Return(ldapUser);
            var postModel = new WorkgroupPeoplePostModel();
            postModel.Role  = RoleRepository.GetNullableById(Role.Codes.AccountManager);
            postModel.Users = new List <string>();
            postModel.Users.Add("1");
            postModel.Users.Add("Me");
            postModel.Users.Add("2");
            postModel.Users.Add("3");
            #endregion Arrange

            #region Act
            var result = Controller.AddPeople(3, postModel, null)
                         .AssertActionRedirect()
                         .ToAction <WorkgroupController>(a => a.People(3, null));
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.RouteValues["id"]);
            Assert.AreEqual(Role.Codes.AccountManager, result.RouteValues["roleFilter"]);

            WorkgroupService.AssertWasCalled(a => a.TryToAddPeople(
                                                 Arg <int> .Is.Anything,
                                                 Arg <Role> .Is.Anything,
                                                 Arg <Workgroup> .Is.Anything,
                                                 Arg <int> .Is.Anything,
                                                 Arg <string> .Is.Anything,
                                                 ref Arg <int> .Ref(Is.Anything(), failCount).Dummy,
                                                 ref Arg <int> .Ref(Is.Anything(), failCount).Dummy,
                                                 Arg <List <KeyValuePair <string, string> > > .Is.Anything), x => x.Repeat.Times(4));

            var args = WorkgroupService.GetArgumentsForCallsMadeOn(a => a.TryToAddPeople(Arg <int> .Is.Anything,
                                                                                         Arg <Role> .Is.Anything,
                                                                                         Arg <Workgroup> .Is.Anything,
                                                                                         Arg <int> .Is.Anything,
                                                                                         Arg <string> .Is.Anything,
                                                                                         ref Arg <int> .Ref(Is.Anything(), failCount).Dummy,
                                                                                         ref Arg <int> .Ref(Is.Anything(), failCount).Dummy,
                                                                                         Arg <List <KeyValuePair <string, string> > > .Is.Anything));

            Assert.AreEqual(4, args.Count());
            Assert.AreEqual(3, args[0][0]);
            Assert.AreEqual("AM", ((Role)args[0][1]).Id);
            Assert.AreEqual(3, ((Workgroup)args[0][2]).Id);
            Assert.AreEqual(0, args[0][3]);
            Assert.AreEqual(7, args[1][3]);
            Assert.AreEqual("1", args[0][4]);
            Assert.AreEqual("Me", args[1][4]);
            Assert.AreEqual("2", args[2][4]);
            Assert.AreEqual("3", args[3][4]);
            Assert.AreEqual(2, args[0][5]);


            Assert.AreEqual("Successfully added 7 people to workgroup as Account Manager. 2 not added because of duplicated role.", Controller.Message);
            #endregion Assert
        }
        public void TestRemoveExtraChildPermissions3()
        {
            #region Arrange
            new FakeUsers(4, UserRepository);
            SetupRoles();

            var workgroups = new List <Workgroup>();
            for (int i = 0; i < 3; i++)
            {
                workgroups.Add(CreateValidEntities.Workgroup(i + 1));
                workgroups[i].Administrative = true; //no child workgroups
            }
            workgroups[1].Administrative = false;
            new FakeWorkgroups(0, RepositoryFactory.WorkgroupRepository, workgroups);

            WorkgroupService.Expect(a => a.GetParentWorkgroups(2)).Return(new List <int>()
            {
                1
            }).Repeat.Any();

            var workgroupPermissions = new List <WorkgroupPermission>();
            for (int i = 0; i < 7; i++)
            {
                workgroupPermissions.Add(CreateValidEntities.WorkgroupPermission(i + 1));
            }

            //Parent Permissions
            workgroupPermissions[0].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[1].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[2].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);

            workgroupPermissions[0].User = UserRepository.Queryable.Single(a => a.Id == "1");
            workgroupPermissions[1].User = UserRepository.Queryable.Single(a => a.Id == "2");
            workgroupPermissions[2].User = UserRepository.Queryable.Single(a => a.Id == "3");

            workgroupPermissions[0].Role = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Approver);
            workgroupPermissions[1].Role = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.AccountManager);
            workgroupPermissions[2].Role = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Purchaser);

            //Child Permissions
            workgroupPermissions[3].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 2);
            workgroupPermissions[4].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 2);
            workgroupPermissions[5].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 2);
            workgroupPermissions[6].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 2);

            //Non Admin permission
            workgroupPermissions[3].User = UserRepository.Queryable.Single(a => a.Id == "4");
            workgroupPermissions[3].Role = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Requester);

            workgroupPermissions[4].User            = UserRepository.Queryable.Single(a => a.Id == "1");
            workgroupPermissions[4].Role            = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Approver);
            workgroupPermissions[4].ParentWorkgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[4].IsAdmin         = true;

            workgroupPermissions[5].User            = UserRepository.Queryable.Single(a => a.Id == "3");
            workgroupPermissions[5].Role            = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Purchaser);
            workgroupPermissions[5].ParentWorkgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[5].IsAdmin         = true;

            workgroupPermissions[6].User            = UserRepository.Queryable.Single(a => a.Id == "2");
            workgroupPermissions[6].Role            = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.AccountManager);
            workgroupPermissions[6].ParentWorkgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[6].IsAdmin         = true;

            workgroupPermissions[6].IsFullFeatured = true; //different from parent

            new FakeWorkgroupPermissions(0, RepositoryFactory.WorkgroupPermissionRepository, workgroupPermissions);
            #endregion Arrange

            #region Act
            Controller.RemoveExtraChildPermissions()
            .AssertActionRedirect()
            .ToAction <AdminController>(a => a.ValidateChildWorkgroups());
            #endregion Act

            #region Assert
            RepositoryFactory.WorkgroupPermissionRepository.AssertWasCalled(a => a.Remove(Arg <WorkgroupPermission> .Is.Anything));
            var args = (WorkgroupPermission)RepositoryFactory.WorkgroupPermissionRepository.GetArgumentsForCallsMadeOn(a => a.Remove(Arg <WorkgroupPermission> .Is.Anything))[0][0];
            Assert.AreEqual(7, args.Id);
            Assert.AreEqual("1 permissions removed", Controller.Message);
            #endregion Assert
        }
        public void TestValidateChildWorkgroupsReturnsView5()
        {
            #region Arrange
            new FakeUsers(4, UserRepository);
            SetupRoles();

            var workgroups = new List <Workgroup>();
            for (int i = 0; i < 3; i++)
            {
                workgroups.Add(CreateValidEntities.Workgroup(i + 1));
                workgroups[i].Administrative = true; //no child workgroups
            }
            workgroups[1].Administrative = false;
            new FakeWorkgroups(0, RepositoryFactory.WorkgroupRepository, workgroups);

            WorkgroupService.Expect(a => a.GetParentWorkgroups(2)).Return(new List <int>()
            {
                1
            }).Repeat.Any();

            var workgroupPermissions = new List <WorkgroupPermission>();
            for (int i = 0; i < 7; i++)
            {
                workgroupPermissions.Add(CreateValidEntities.WorkgroupPermission(i + 1));
            }

            //Parent Permissions
            workgroupPermissions[0].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[1].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 3); //This one not there
            workgroupPermissions[2].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);

            workgroupPermissions[0].User = UserRepository.Queryable.Single(a => a.Id == "1");
            workgroupPermissions[1].User = UserRepository.Queryable.Single(a => a.Id == "2");
            workgroupPermissions[2].User = UserRepository.Queryable.Single(a => a.Id == "3");

            workgroupPermissions[0].Role = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Approver);
            workgroupPermissions[1].Role = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.AccountManager);
            workgroupPermissions[2].Role = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Purchaser);

            //Child Permissions
            workgroupPermissions[3].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 2);
            workgroupPermissions[4].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 2);
            workgroupPermissions[5].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 2);
            workgroupPermissions[6].Workgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 2);

            //Non Admin permission
            workgroupPermissions[3].User = UserRepository.Queryable.Single(a => a.Id == "4");
            workgroupPermissions[3].Role = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Requester);

            workgroupPermissions[4].User            = UserRepository.Queryable.Single(a => a.Id == "1");
            workgroupPermissions[4].Role            = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Approver);
            workgroupPermissions[4].ParentWorkgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[4].IsAdmin         = true;

            workgroupPermissions[5].User            = UserRepository.Queryable.Single(a => a.Id == "3");
            workgroupPermissions[5].Role            = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.Purchaser);
            workgroupPermissions[5].ParentWorkgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[5].IsAdmin         = true;

            workgroupPermissions[6].User            = UserRepository.Queryable.Single(a => a.Id == "2");
            workgroupPermissions[6].Role            = RoleRepository.Queryable.Single(a => a.Id == Role.Codes.AccountManager);
            workgroupPermissions[6].ParentWorkgroup = RepositoryFactory.WorkgroupRepository.Queryable.Single(a => a.Id == 1);
            workgroupPermissions[6].IsAdmin         = true;

            new FakeWorkgroupPermissions(0, RepositoryFactory.WorkgroupPermissionRepository, workgroupPermissions);
            #endregion Arrange

            #region Act
            var result = Controller.ValidateChildWorkgroups()
                         .AssertViewRendered()
                         .WithViewData <List <ValidateChildWorkgroupsViewModel> >();
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(1, result[0].ExtraChildPermissions.Count);
            Assert.AreEqual(0, result[0].MissingChildPermissions.Count);
            //Assert.AreEqual(false, result[0].MissingChildPermissions[0].IsFullFeatured);
            //Assert.AreEqual(Role.Codes.AccountManager, result[0].MissingChildPermissions[0].Role.Id);
            //Assert.AreEqual("2", result[0].MissingChildPermissions[0].User.Id);
            //Assert.AreEqual(1, result[0].MissingChildPermissions[0].Workgroup.Id);

            Assert.AreEqual(false, result[0].ExtraChildPermissions[0].IsFullFeatured);
            Assert.AreEqual(Role.Codes.AccountManager, result[0].ExtraChildPermissions[0].Role.Id);
            Assert.AreEqual("2", result[0].ExtraChildPermissions[0].User.Id);
            Assert.AreEqual(2, result[0].ExtraChildPermissions[0].Workgroup.Id);
            Assert.AreEqual(1, result[0].ExtraChildPermissions[0].ParentWorkgroup.Id);
            #endregion Assert
        }