public void TestComponents() { SODesignAlternative alternative = new SODesignAlternative("default"); // Components should not be null Assert.NotNull(alternative.Components); // Components should be empty on the start Assert.IsEmpty(alternative.Components); // Add a component SOComponent component = new SOComponent("default"); alternative.AddComponent(component); // Components should no longer be empty Assert.IsNotEmpty(alternative.Components); Assert.AreEqual(1, alternative.Components.Length); // Component should match Assert.AreEqual(component, alternative.Components[0]); // Clear the components alternative.ClearComponents(); // Components should be empty on the start Assert.IsEmpty(alternative.Components); }
/// <summary> /// Adds an alternative to the design /// </summary> /// <param name="alternative">Alternative to add</param> public void AddAlternative(SODesignAlternative alternative) { if (this.m_Alternatives == null) { this.ReInit(); } this.m_Alternatives.Add(alternative); this.m_CurrentIndex = this.m_Alternatives.Count - 1; }
public void TestAddAlternative() { SODesign design = new SODesign("test_design"); // design should not be null Assert.NotNull(design); // first design alternative should be the default one Assert.IsNotEmpty(design.Alternatives); Assert.AreEqual(1, design.Alternatives.Length); Assert.AreEqual(SODesign.DEFAULT_ALTERNATIVE_NAME, design.Alternatives[0].Name); // add an alternative SODesignAlternative alternative = new SODesignAlternative("alternative_0001"); design.AddAlternative(alternative); // second design alternative should now exist Assert.AreEqual(2, design.Alternatives.Length); Assert.AreEqual("alternative_0001", design.Alternatives[1].Name); }
public void TestCurrentAlternative() { SODesign design = new SODesign("test_design"); // design should not be null Assert.NotNull(design); // current alternative should be the first alternative Assert.AreEqual(1, design.Alternatives.Length); Assert.NotNull(design.CurrentAlternative); Assert.AreEqual(SODesign.DEFAULT_ALTERNATIVE_NAME, design.CurrentAlternative.Name); SODesignAlternative alternative = new SODesignAlternative("alternative_0001"); design.AddAlternative(alternative); // current alternative should be the second alternative Assert.AreEqual(2, design.Alternatives.Length); Assert.NotNull(design.CurrentAlternative); Assert.AreEqual("alternative_0001", design.CurrentAlternative.Name); }
public void TestFlattenedComponents() { SODesignAlternative alternative = new SODesignAlternative("default"); // Components should not be null Assert.NotNull(alternative.Components); // Components should be empty on the start Assert.IsEmpty(alternative.Components); // Add a component SOComponent component1 = new SOComponent("0001"); SOComponent component2 = new SOComponent("0002"); SOComponent component3 = new SOComponent("0003"); SOComponent component4 = new SOComponent("0004"); SOComponent component5 = new SOComponent("0005"); alternative.AddComponent(component1); component1.AddSubComponent(component2); component2.AddSubComponent(component3); component1.AddSubComponent(component4); alternative.AddComponent(component5); // FlattenedComponents should contain a list of 5 components now Assert.IsNotEmpty(alternative.FlattenedComponents); Assert.AreEqual(5, alternative.FlattenedComponents.Length); }
/// <summary> /// Adds an alternative to the design /// </summary> /// <param name="alternative">Alternative to add</param> public void AddAlternative(SODesignAlternative alternative) { if (this.m_Alternatives == null) { this.ReInit(); } this.m_Alternatives.Add(alternative); this.m_CurrentIndex = this.m_Alternatives.Count - 1; }