public void Edit_User_Add_Membership_User_Gets_Filters()
        {
            // Assign
            ConsoleRepository c1 = new ConsoleRepository();
            AdminModuleManager a1 = new AdminModuleManager(c1, new LogHandler(), context.Object, new WebSiteModuleManager(c1, context.Object));

            var dto = a1.GetUser(newUserId);
            dto.TeamMemberships = new List<TeamMembershipDto>();
            dto.TeamMemberships.Add(new DTO.TeamMembershipDto()
            {
                Team = new TeamDto() { Id = TeamAId },
                UserId = newUserId,
                PrimaryTeamMembership = true
            });
            
            // Act
            ConsoleRepository c = new ConsoleRepository();
            AdminModuleManager a = new AdminModuleManager(c, new LogHandler(), context.Object, new WebSiteModuleManager(c, context.Object));
            var result = a.EditUser(dto);

            ConsoleRepository c2 = new ConsoleRepository();
            AdminModuleManager a2 = new AdminModuleManager(c2, new LogHandler(), context.Object, new WebSiteModuleManager(c2, context.Object));
            var dtoafter = a2.GetUser(newUserId);

            // Assert
            Assert.AreEqual(dtoafter.FilterCOBs.Count, 3);
        }        
        public static void ClassCleanup()
        {
            if (_actualTestTeam != null)
            {
                var consoleRepository1 = new ConsoleRepository();
                var adminModuleManager1 = new AdminModuleManager(consoleRepository1, _logHandler, _mockCurrentHttpContext.Object, new WebSiteModuleManager(consoleRepository1, _mockCurrentHttpContext.Object));
                var teamToDelete = adminModuleManager1.GetTeam(_actualTestTeam.Id);

                if (teamToDelete != null)
                {
                    var consoleRepository2 = new ConsoleRepository();
                    var adminModuleManager2 = new AdminModuleManager(consoleRepository2, _logHandler, _mockCurrentHttpContext.Object, new WebSiteModuleManager(consoleRepository2, _mockCurrentHttpContext.Object));
                    adminModuleManager2.DeleteTeam(teamToDelete);
                }
            }

            if (_testTeam != null)
            {
                var consoleRepository1 = new ConsoleRepository();
                var adminModuleManager3 = new AdminModuleManager(consoleRepository1, _logHandler, _mockCurrentHttpContext.Object, new WebSiteModuleManager(consoleRepository1, _mockCurrentHttpContext.Object));
                var teamToDelete = adminModuleManager3.GetTeam(_testTeam.Id);

                if (teamToDelete != null)
                {
                    var consoleRepository2 = new ConsoleRepository();
                    var adminModuleManager4 = new AdminModuleManager(consoleRepository2, _logHandler, _mockCurrentHttpContext.Object, new WebSiteModuleManager(consoleRepository2, _mockCurrentHttpContext.Object));
                    adminModuleManager4.DeleteTeam(teamToDelete);
                }
            }
        }
        public static void ClassInit(TestContext context)
        {
            _container = new UnityContainer();
            _container.AddNewExtension<EnterpriseLibraryCoreExtension>();
            using (IConsoleRepository repository = _container.Resolve<ConsoleRepository>())
            {
                var team = repository.Query<Team>(t=>t.RelatedOffices).FirstOrDefault(t => t.Title == "New Test Team");
                if (team != null)
                {
                    repository.Attach<Team>(team);
                    repository.Delete<Team>(team);
                    repository.SaveChanges();
                }
            }

            using (IConsoleRepository repository = _container.Resolve<ConsoleRepository>())
            {
                var team = repository.Query<Team>(t => t.RelatedOffices).FirstOrDefault(t => t.Title == "Test Team");
                if (team != null)
                {
                    repository.Attach<Team>(team);
                    repository.Delete<Team>(team);
                    repository.SaveChanges();
                }
            }

            _logHandler = new LogHandler();
            var consoleRepository = new ConsoleRepository();
            _mockCurrentHttpContext = new Mock<CurrentHttpContext>();
            _mockCurrentHttpContext.Setup(h => h.CurrentUser).Returns(new GenericPrincipal(new GenericIdentity(@"talbotdev\MurrayE"), null));
            _mockCurrentHttpContext.Setup(h => h.Context).Returns(MvcMockHelpers.FakeHttpContextWithSession());

            var adminModuleManager = new AdminModuleManager(consoleRepository, _logHandler, _mockCurrentHttpContext.Object, new WebSiteModuleManager(consoleRepository, _mockCurrentHttpContext.Object));
            _editUserDto = adminModuleManager.GetUser(4);

            var consoleRepository2 = new ConsoleRepository();
            var adminModuleManager2 = new AdminModuleManager(consoleRepository2, _logHandler, _mockCurrentHttpContext.Object, new WebSiteModuleManager(consoleRepository2, _mockCurrentHttpContext.Object));
            var teamDto = new TeamDto { Title = "Test Team", QuoteExpiryDaysDefault = 2, DefaultPolicyType = "MARINE" };
            _testTeam = adminModuleManager2.CreateTeam(teamDto);
        }
        public void AddMarketWording()
        {
            using (IConsoleRepository rep = new ConsoleRepository())
            {
                var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object));
                adminModuleManager.CreateMarketWording(new MarketWording
                    {
                        WordingRefNumber = "MTEST01",
                        Title = "MTEST01"
                    });

            }
            using (IConsoleRepository rep = new ConsoleRepository())
            {
                var tempTotalMarketWording = rep.Query<MarketWording>(mw => true).Count();
                Assert.AreEqual(_totalMarketWording + 1, tempTotalMarketWording);
                _totalMarketWording = tempTotalMarketWording;
            }
        }
        public void SaveSubjectToClauseWordingsForTeamOffice()
        {
            using (IConsoleRepository rep = new ConsoleRepository())
            {
                var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object));
                adminModuleManager.CreateSubjectToClauseWording(new SubjectToClauseWording
                {
                    WordingRefNumber = "STEST04",
                    Title = "STEST04"
                });
            }

            using (IConsoleRepository rep = new ConsoleRepository())
            {
                var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object));
                var tempSubjectToClauseWording = rep.Query<SubjectToClauseWording>(sw => sw.Title == "STEST04").First();
                var subjectToClauseWordingSettingDto = new SubjectToClauseWordingSettingDto
                {
                    Id = tempSubjectToClauseWording.Id,
                    DisplayOrder = 1,
                    Title = "STEST04"
                };


                var teamSubjectToClauseWordingsDto = new TeamSubjectToClauseWordingsDto
                {
                    TeamId = rep.Query<Team>(t => t.Title == "TestTeam").First().Id,
                    OfficeId = "LON",
                    SubjectToClauseWordingSettingDtoList = new List<SubjectToClauseWordingSettingDto> { subjectToClauseWordingSettingDto }
                };
                adminModuleManager.SaveSubjectToClauseWordingsForTeamOffice(teamSubjectToClauseWordingsDto);
            }

            using (IConsoleRepository rep = new ConsoleRepository())
            {
                var team = rep.Query<Team>(t => t.Title == "TestTeam",
                                t => t.TeamOfficeSettings.Select(tos => tos.SubjectToClauseWordingSettings.Select(sw => sw.SubjectToClauseWording))).First();
                Assert.AreEqual("STEST04",
                                team.TeamOfficeSettings.First().SubjectToClauseWordingSettings.First().SubjectToClauseWording.Title);
                _totalSubjectToClauseWording = _totalSubjectToClauseWording + 1;
            }


        }
 public void DeleteSubjectToClauseWording()
 {
     using (IConsoleRepository rep = new ConsoleRepository())
     {
         var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object));
         adminModuleManager.CreateSubjectToClauseWording(new SubjectToClauseWording
         {
             WordingRefNumber = "STEST03",
             Title = "STEST03"
         });
     }
     using (IConsoleRepository rep = new ConsoleRepository())
     {
         var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object));
         var tempSubjectToClauseWording = rep.Query<SubjectToClauseWording>(sw => sw.Title == "STEST03").First();
         adminModuleManager.DeleteSubjectToClauseWording(tempSubjectToClauseWording);
     }
     using (IConsoleRepository rep = new ConsoleRepository())
     {
         var tempTotalSubjectToClauseWording = rep.Query<SubjectToClauseWording>(sw => true).Count();
         var tempSubjectToClauseWording = rep.Query<SubjectToClauseWording>(sw => sw.Title == "STEST03").FirstOrDefault();
         Assert.AreEqual(_totalSubjectToClauseWording, tempTotalSubjectToClauseWording);
         Assert.IsNull(tempSubjectToClauseWording);
     }
 }
        public void EditTermsNConditionWording()
        {
            using (IConsoleRepository rep = new ConsoleRepository())
            {
                var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object));
                adminModuleManager.CreateTermsNConditionWording(new TermsNConditionWording
                {
                    WordingRefNumber = "TTEST02",
                    Title = "TTEST02"
                });

            }
            using (IConsoleRepository rep = new ConsoleRepository())
            {
                var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object));
                var tempTermsNConditionWording = rep.Query<TermsNConditionWording>(tnc => tnc.Title == "TTEST02").First();
                tempTermsNConditionWording.Title = "TTEST02_Changed";

                adminModuleManager.EditTermsNConditionWording(tempTermsNConditionWording);

            }
            using (IConsoleRepository rep = new ConsoleRepository())
            {
                var tempTotalTermsNConditionWording = rep.Query<TermsNConditionWording>(tnc => true).Count();
                var tempTermsNConditionWording = rep.Query<TermsNConditionWording>(tnc => tnc.Title == "TTEST02_Changed").First();
                var tempOldTermsNConditionWording = rep.Query<TermsNConditionWording>(tnc => tnc.Title == "TTEST02").FirstOrDefault();
                Assert.AreEqual(_totalTermsNConditionWording + 1, tempTotalTermsNConditionWording);
                Assert.IsNotNull(tempTermsNConditionWording);
                Assert.IsNull(tempOldTermsNConditionWording);
                _totalTermsNConditionWording = tempTotalTermsNConditionWording;
            }
        }
        public void EditTeam_Success()
        {
            // Assign
            var logHandler = new LogHandler();
            var consoleRepository = new ConsoleRepository();
            var mockHttpContext = new Mock<ICurrentHttpContext>();
            mockHttpContext.Setup(h => h.CurrentUser).Returns(new GenericPrincipal(new GenericIdentity(@"talbotdev\MurrayE"), null));

            var adminModuleManager = new AdminModuleManager(consoleRepository, logHandler, mockHttpContext.Object, new WebSiteModuleManager(consoleRepository, mockHttpContext.Object));

            // Act
            _testTeam.Title = "Edit Team - new name...";
            var updatedTeam = adminModuleManager.EditTeam(_testTeam);

            // Assert
            Assert.AreEqual("Edit Team - new name...", updatedTeam.Title);
        }