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 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); }