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 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); }
public void TestInit() { var logHandler = new LogHandler(); var consoleRepository = new ConsoleRepository(); var mockHttpContext = new Mock<CurrentHttpContext>(); mockHttpContext.Setup(h => h.CurrentUser).Returns(new GenericPrincipal(new GenericIdentity(@"talbotdev\MurrayE"), null)); mockHttpContext.Setup(h => h.Context).Returns(MvcMockHelpers.FakeHttpContextWithSession()); _adminModuleManager = new AdminModuleManager(consoleRepository, logHandler, mockHttpContext.Object, new WebSiteModuleManager(consoleRepository, _mockCurrentHttpContext.Object)); }