public void Ctor( ) { IUserRoleRepository userRoleRepository; ConsoleTreeRepository consoleTreeRepository; userRoleRepository = new Mock <IUserRoleRepository>(MockBehavior.Strict).Object; consoleTreeRepository = new ConsoleTreeRepository(userRoleRepository); Assert.That(consoleTreeRepository, Has.Property("UserRoleRepository").EqualTo(userRoleRepository)); }
public void ShouldPrune_NullEntityData( ) { IUserRoleRepository userRoleRepository; ConsoleTreeRepository consoleTreeRepository; userRoleRepository = new Mock <IUserRoleRepository>(MockBehavior.Strict).Object; consoleTreeRepository = new ConsoleTreeRepository(userRoleRepository); long userId = 1; Assert.That( () => !consoleTreeRepository.CanSeeElement(null, new HashSet <long>( ), userId, false), Throws.TypeOf <ArgumentNullException>( ).And.Property("ParamName").EqualTo("entityData")); }
public void PrivateReportVisibleToSelf(string viewBy, bool expectVisible) { UserAccount user1 = CreateSelfServeUser("user1"); NavContainer folder = Entity.Get <NavContainer>("console:homeSection"); IUserRoleRepository userRoleRepository; IConsoleTreeRepository consoleTreeRepository; Report report = Entity.Create <Report>( ); report.ResourceInFolder.Add(folder); report.IsPrivatelyOwned = true; report.SecurityOwner = user1; report.Save( ); UserAccount viewingUser = null; switch (viewBy) { case "self": viewingUser = user1; break; case "other": viewingUser = CreateSelfServeUser("user2"); break; case "admin": viewingUser = Entity.Get <UserAccount>("core:administratorUserAccount"); break; } using (new SetUser(viewingUser)) { userRoleRepository = Factory.Current.Resolve <IUserRoleRepository>( ); consoleTreeRepository = new ConsoleTreeRepository(userRoleRepository); EntityData tree = consoleTreeRepository.GetTree( ); EntityData homeTopMenu = tree.GetRelationship("core:instancesOfType", Direction.Forward).Instances [0].Entity; EntityData homeSection = homeTopMenu.GetRelationship("console:folderContents", Direction.Forward).Instances [0].Entity; List <RelationshipInstanceData> contents = homeSection.GetRelationship("console:folderContents", Direction.Forward).Instances; bool containsReport = contents.Any(e => e.Entity.Id.Id == report.Id); Assert.That(containsReport, Is.EqualTo(expectVisible)); } }