public void RemoveConnection() { IExperiment experiment = ExperimentManager.New(); experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml"; ComponentMetadataDefinition def1 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test.dll"), "IDontExist"); ExperimentNode node1 = ((IEditableExperiment)experiment).AddComponentFromDefinition(def1, -5, 5); ComponentMetadataDefinition def2 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test2.dll"), "IDontExistEither"); ExperimentNode node2 = ((IEditableExperiment)experiment).AddComponentFromDefinition(def2, -5, 5); Assert.AreEqual(0, experiment.EdgeCount); ExperimentNodeConnection newEdge = ((IEditableExperiment)experiment).AddConnection(node1, node2); Assert.IsNotNull(newEdge); Assert.AreEqual(1, experiment.EdgeCount); experiment.ResetModifiedFlag(); Assert.AreEqual(4, experiment.VertexCount); ((IEditableExperiment)experiment).RemoveConnection(newEdge); // Verify that the edge was existed and the number of vertices was unaffected. Assert.AreEqual(0, experiment.EdgeCount); Assert.AreEqual(4, experiment.VertexCount); Assert.IsTrue(experiment.IsModified); }
public void AddNewConnectionNullNode1() { IExperiment experiment = ExperimentManager.New(); experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml"; ComponentMetadataDefinition def1 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test.dll"), "IDontExist"); ExperimentNode node1 = ((IEditableExperiment)experiment).AddComponentFromDefinition(def1, -5, 5); experiment.ResetModifiedFlag(); Assert.AreEqual(0, experiment.EdgeCount); ExperimentNodeConnection newEdge = ((IEditableExperiment)experiment).AddConnection(node1, null); Assert.IsNotNull(newEdge); Assert.AreEqual(1, experiment.EdgeCount); }
// HERZUM SPRINT 3: TLAB-86 public static bool PublishTeml(IExperiment experiment, string filePath) { if (experiment == null) { throw new ArgumentNullException("experiment"); } if (IsFileReadOnly(filePath)) { throw new System.IO.IOException("File Is Read Only"); } bool success = SerializeExperimentToXml(experiment, filePath); if (success) { experiment.ResetModifiedFlag(); } return(success); }
public void AddNewConnection() { IExperiment experiment = ExperimentManager.New(); experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml"; ComponentMetadataDefinition def1 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test.dll"), "IDontExist"); ExperimentNode node1 = ((IEditableExperiment)experiment).AddComponentFromDefinition(def1, -5, 5); ComponentMetadataDefinition def2 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test2.dll"), "IDontExistEither"); ExperimentNode node2 = ((IEditableExperiment)experiment).AddComponentFromDefinition(def2, -5, 5); // We know already that experiments are modified after adding components, but we // want to make sure that they're modified after adding a connection too, so lets clear the modification flag first. experiment.ResetModifiedFlag(); Assert.IsFalse(experiment.IsModified); Assert.AreEqual(0, experiment.EdgeCount); ExperimentNodeConnection newEdge = ((IEditableExperiment)experiment).AddConnection(node1, node2); Assert.IsNotNull(newEdge); Assert.AreEqual(1, experiment.EdgeCount); Assert.IsTrue(experiment.IsModified); }
/// <summary> /// Saves the experiment to specified filename. /// </summary> /// <param name="experiment">The experiment to be saved.</param> /// <param name="fileName">The filename.</param> /// <returns>true if saving was successful, otherwise false</returns> private static bool Save(IExperiment experiment) { if (experiment == null) { throw new ArgumentNullException("experiment"); } if (String.IsNullOrEmpty(experiment.ExperimentInfo.FilePath)) { throw new InvalidOperationException("experiment filepath"); } if (IsFileReadOnly(experiment.ExperimentInfo.FilePath)) { throw new System.IO.IOException("File Is Read Only"); } bool success = SerializeExperimentToXml(experiment, experiment.ExperimentInfo.FilePath); if (success) { experiment.ResetModifiedFlag(); } return(success); }
/// <summary> /// Saves the experiment to specified filename. /// </summary> /// <param name="experiment">The experiment to be saved.</param> /// <param name="fileName">The filename.</param> /// <returns>true if saving was successful, otherwise false</returns> private static bool Save(IExperiment experiment) { if (experiment == null) throw new ArgumentNullException("experiment"); if (String.IsNullOrEmpty(experiment.ExperimentInfo.FilePath)) throw new InvalidOperationException("experiment filepath"); if (IsFileReadOnly(experiment.ExperimentInfo.FilePath)) throw new System.IO.IOException("File Is Read Only"); bool success = SerializeExperimentToXml(experiment, experiment.ExperimentInfo.FilePath); if (success) { experiment.ResetModifiedFlag(); } return success; }
// HERZUM SPRINT 3: TLAB-86 public static bool PublishTeml(IExperiment experiment, string filePath) { if (experiment == null) throw new ArgumentNullException("experiment"); if (IsFileReadOnly(filePath)) throw new System.IO.IOException("File Is Read Only"); bool success = SerializeExperimentToXml(experiment, filePath); if (success) { experiment.ResetModifiedFlag(); } return success; }
public void ResetModifiedFlag() { m_experiment.ResetModifiedFlag(); }