public void AddListTestNullValue() { FileDependencyCollection collection = new FileDependencyCollection(); try { collection.Add((FileDependency[])null); Assert.IsTrue(false, "Adding a null value to the collection should throw an InvalidOretationException."); } catch (InvalidOperationException e) { Console.Write(e); // pass if we get here Assert.IsTrue(true); } }
public void AddListTestDuplicatedValue() { FileDependencyCollection collection = new FileDependencyCollection(); FileDependency[] fdList = new FileDependency[1]; FileDependency fd1 = new FileDependencyTestFiller(@"c:\test1.txt"); fdList[0] = new FileDependencyTestFiller(@"c:\test1.txt"); collection.Add(fd1); try { collection.Add(fdList); Assert.IsTrue(false, "Adding a duplicate value to the collection should throw an InvalidOretationException."); } catch (InvalidOperationException e) { Console.Write(e); // pass if we get here Assert.IsTrue(true); } }
//----------------------------------------------------------------------------------------------- /// <summary> /// Sets the manifest for the application, which consists for the input/output dependencies for this application. /// </summary> /// <param name="sc">security credentials to verify if the owner has permission to perform this operation /// (i.e SetApplicationManifest, which is associated with the ManageOwnApp permission)</param> /// <param name="appId">application whose manifest needs to be set</param> /// <param name="manifest">the manifest to set</param> public void Owner_SetApplicationManifest(SecurityCredentials sc, string appId, FileDependencyCollection manifest) { AuthenticateUser(sc); ApplicationAuthorizationCheck(sc, appId); logger.Debug("Setting manifest for application: "+appId); _Applications[appId].Manifest = manifest; }
/// <summary> /// Creates a task on the Manager from the provided XML task representation and returns its Id. /// </summary> /// <param name="manager"></param> /// <param name="sc">Security Credentials</param> /// <param name="taskXml"></param> /// <returns>application id</returns> public static string CreateTask(IManager manager, SecurityCredentials sc, string taskXml) { // TODO: validate against schema string taskId = manager.Owner_CreateApplication(sc); XmlDocument doc = new XmlDocument(); doc.LoadXml(taskXml); FileDependencyCollection manifest = new FileDependencyCollection(); foreach (XmlNode manifestFile in doc.SelectNodes("task/manifest/embedded_file")) { EmbeddedFileDependency dep = new EmbeddedFileDependency(manifestFile.Attributes["name"].Value); dep.Base64EncodedContents = manifestFile.InnerText; manifest.Add(dep); logger.Debug("Added dependency to manifest: " + dep.FileName); } manager.Owner_SetApplicationManifest(sc, taskId, manifest); foreach (XmlNode jobXml in doc.SelectNodes("task/job")) { int jobId = int.Parse(jobXml.Attributes["id"].Value); jobXml.Attributes.Remove(jobXml.Attributes["id"]); // TODO: allow setting of priority in xml file AddJob(manager, sc, taskId, jobId, 0, jobXml.OuterXml); logger.Debug("Added job to manager: " + jobId); } return taskId; }
public void ContainsTestEmptyCollection() { FileDependencyCollection collection = new FileDependencyCollection(); FileDependency fd = new FileDependencyTestFiller(@"c:\tst.txt"); bool result = collection.Contains(fd); Assert.IsFalse(result); }
public void ContainsTestNullValue() { FileDependencyCollection collection = new FileDependencyCollection(); bool result = collection.Contains(null); Assert.IsFalse(result); }
public void ContainsTestDependencyNotFound() { FileDependencyCollection collection = new FileDependencyCollection(); FileDependency fd1 = new FileDependencyTestFiller(@"c:\test1.txt"); FileDependency fd2 = new FileDependencyTestFiller(@"c:\test2.txt"); FileDependency fd3 = new FileDependencyTestFiller(@"c:\test3.txt"); collection.Add(fd1); collection.Add(fd2); bool result = collection.Contains(fd3); Assert.IsFalse(result); }
public void ContainsTestDependencyFoundCaseOnlyDifferent() { FileDependencyCollection collection = new FileDependencyCollection(); FileDependency fd1 = new FileDependencyTestFiller(@"c:\test1.txt"); FileDependency fd2 = new FileDependencyTestFiller(@"c:\test2.txt"); FileDependency fd3 = new FileDependencyTestFiller(@"c:\TEST2.txt"); collection.Add(fd1); collection.Add(fd2); bool result = collection.Contains(fd3); Assert.IsTrue(result); }
public void AddTestSimpleScenario() { FileDependencyCollection collection = new FileDependencyCollection(); FileDependency fd1 = new FileDependencyTestFiller(@"c:\test1.txt"); FileDependency fd2 = new FileDependencyTestFiller(@"c:\test2.txt"); collection.Add(fd1); collection.Add(fd2); Assert.IsTrue(collection.Contains(fd1)); Assert.IsTrue(collection.Contains(fd2)); }
public void AddListTestSimpleScenario() { FileDependencyCollection collection = new FileDependencyCollection(); FileDependency[] fdList = new FileDependency[2]; FileDependency fd1 = new FileDependencyTestFiller(@"c:\test1.txt"); FileDependency fd2 = new FileDependencyTestFiller(@"c:\test2.txt"); fdList[0] = fd1; fdList[1] = fd2; collection.Add(fdList); Assert.IsTrue(collection.Contains(fd1)); Assert.IsTrue(collection.Contains(fd2)); }
public void ContainsTestDependencyFound() { FileDependencyCollection collection = new FileDependencyCollection(); FileDependency fd1 = new FileDependencyMock(@"c:\test1.txt"); FileDependency fd2 = new FileDependencyMock(@"c:\test2.txt"); collection.Add(fd1); collection.Add(fd2); bool result = collection.Contains(fd1); Assert.IsTrue(result); }