private void Duplicate() { if (this.listBoxUnitSystems.SelectedItem != null) { UnitSystem unitSystem = (UnitSystem)this.listBoxUnitSystems.SelectedItem; UnitSystem us = unitSystem.Clone(); us.IsReadOnly = false; us.Name = "Copy of " + unitSystem.Name; UnitSystemService.GetInstance().GetUnitSystemCatalog().Add(us); } }
public void Clone_EmptySystem_ReturnsEmptySystem() { // Arrange UnitSystem system = new UnitSystem(); // Act UnitSystem clone = (UnitSystem)system.Clone(); // Assert Assert.NotNull(clone); CollectionAssert.IsEmpty(clone.Dimensions); }
public void Clone_SingleDimensionSystem_ResultHasSameDimension() { // Arrange var mockConverter = new Mock <IValueConverter>(); UnitSystem system = new UnitSystem(); IDimension dimension = CreateStubDimension("M"); IUnit baseunit = CreateStubUnit("base", dimension); IUnit scaledunit = CreateStubUnit("scaled", dimension); system.AddDimension(dimension); system.AddBaseUnit(baseunit); system.AddScaledUnit(baseunit, scaledunit, mockConverter.Object); // Act UnitSystem clone = (UnitSystem)system.Clone(); // Assert CollectionAssert.AreEquivalent(system.Dimensions, clone.Dimensions); }