public void CondoPermission_Must_Not_Add_RepeatedFunctionality_With_LowerRole() { var condoPermission = new CondoPermission { Condo = 1 }; var firstPermission = new Permission { Functionality = "Entregas", Role = Role.Escrita }; var secondPermission = new Permission { Functionality = "Entregas", Role = Role.Leitura }; condoPermission.AddPermisson(firstPermission); condoPermission.AddPermisson(secondPermission); Assert.IsTrue(condoPermission.Permissions.Count == 1); Assert.IsFalse(condoPermission.Permissions.Contains(secondPermission)); }
private List <CondoPermission> FindCondoPermissons(User user) { var condoPermissons = new List <CondoPermission>(); foreach (var userGroup in user.Groups) { var group = FindGroup(userGroup.GroupType, userGroup.Condo); var condoPermisson = condoPermissons.FirstOrDefault(c => c.Condo == group.Condo); if (condoPermisson == null) { condoPermisson = new CondoPermission { Condo = group.Condo }; condoPermissons.Add(condoPermisson); } foreach (var permission in group.Permissions) { condoPermisson.AddPermisson(permission); } } return(condoPermissons); }
public void CondoPermission_Must_Not_Add_RepeatedPermission() { var condoPermission = new CondoPermission { Condo = 1 }; var firstPermission = new Permission { Functionality = "Entregas", Role = Role.Escrita }; condoPermission.AddPermisson(firstPermission); condoPermission.AddPermisson(firstPermission); Assert.IsTrue(condoPermission.Permissions.Count == 1); }
public void CondoPermission_Must_Add_New_Permission() { var condoPermission = new CondoPermission { Condo = 1 }; var permission = new Permission { Functionality = "Entregas", Role = Role.Escrita }; condoPermission.AddPermisson(permission); Assert.IsTrue(condoPermission.Permissions.Count > 0); Assert.IsTrue(condoPermission.Permissions.Contains(permission)); }