public void It_Should_Get_All_The_Scripts() { var scripts = _scriptsRepository.GetAll(); Assert.AreEqual(3, scripts.Count()); Assert.AreEqual("test-script-1", scripts.First().Key); Assert.AreEqual("Test Script 1", scripts.First().Name); Assert.AreEqual("Description Test Script 1", scripts.First().Description); Assert.AreEqual(@"C:\test-script-1.bat", scripts.First().Path); Assert.AreEqual("arguments-1", scripts.First().Arguments); Assert.AreEqual(1, scripts.First().Delay); Assert.AreEqual(10, scripts.First().Timeout); }
public IEnumerable <ScriptModel> GetUsersScripts(string userName, IEnumerable <string> userGroups) { var scripts = _scriptsRepository.GetAll(); var authorizations = _authorizationsRepository.GetAll(); return(authorizations .Where(authorization => (authorization.Type == AuthorizationType.User && authorization.Target == userName) || (authorization.Type == AuthorizationType.Group && userGroups != null && userGroups.Contains(authorization.Target))) .SelectMany(authorization => authorization.Scripts) .Distinct().OrderBy(script => script) .Select(scriptKey => scripts.FirstOrDefault(script => script.Key == scriptKey))); }
public List <Scripts> GetAll() { return(_repo.GetAll()); }