public void CloneAs_SiblingClass()
        {
            // arrange
            var orig = MachineProfilesFactoryFFF.Prusa.Create_i3Mk3();

            // act
            var clone = SettingsPrototype.CloneAs <MachineProfileFFF, MachineProfileFFF>(orig);

            // assert
            Assert.IsNotNull(clone);
        }
Ejemplo n.º 2
0
        public void CloneFromChild()
        {
            var orig = new SettingsB();

            orig.IntegerFieldA = 4;

            var copy = SettingsPrototype.CloneAs <SettingsA, SettingsB>(orig);

            Assert.IsNotNull(copy);
            Assert.AreEqual(4, copy.IntegerFieldA);
        }
Ejemplo n.º 3
0
        public void Clone_FloatArray()
        {
            var orig = new SettingsH();

            orig.FloatArray[0, 0] = 10;

            var copy = SettingsPrototype.CloneAs <SettingsH, SettingsH>(orig);

            orig.FloatArray[0, 0] = 99;

            Assert.AreEqual(10, copy.FloatArray[0, 0]);
        }
Ejemplo n.º 4
0
        public void Clone_ReferenceTypesIndependant()
        {
            var orig = new SettingsD();

            orig.SubSettings.SubFieldX = 1;

            var copy = SettingsPrototype.CloneAs <SettingsD, SettingsD>(orig);

            orig.SubSettings.SubFieldX = 2;

            Assert.AreEqual(1, copy.SubSettings.SubFieldX);
        }
Ejemplo n.º 5
0
        public void Clone_StringsIndependant()
        {
            var orig = new SettingsA();

            orig.StringFieldA = "hello";

            var copy = SettingsPrototype.CloneAs <SettingsA, SettingsA>(orig);

            orig.StringFieldA = "world";

            Assert.AreEqual("hello", copy.StringFieldA);
        }
Ejemplo n.º 6
0
        public void Clone_DoubleList()
        {
            var orig = new SettingsWithListOfDouble();

            orig.ListOfDouble.Add(9);

            var copy = SettingsPrototype.CloneAs <
                SettingsWithListOfDouble, SettingsWithListOfDouble>(orig);

            orig.ListOfDouble[0] = 7;
            orig.ListOfDouble[1] = 8;

            Assert.AreEqual(3, copy.ListOfDouble.Count);
            Assert.AreEqual(0, copy.ListOfDouble[0]);
            Assert.AreEqual(1, copy.ListOfDouble[1]);
            Assert.AreEqual(9, copy.ListOfDouble[2]);
        }
        public void CloneAs_ValuesCloneCorrectly()
        {
            // arrange
            var orig = new PrintProfileFFF();

            orig.Part.Shells              = 10;
            orig.Machine.NozzleDiamMM     = 20;
            orig.Machine.ManufacturerName = "A";

            // act
            var copy = SettingsPrototype.CloneAs <PrintProfileFFF, PrintProfileFFF>(orig);

            // assert
            Assert.AreEqual(10, copy.Part.Shells);
            Assert.AreEqual(20, copy.Machine.NozzleDiamMM);
            Assert.AreEqual("A", orig.Machine.ManufacturerName);
            Assert.AreNotSame(copy.Machine, orig.Machine);
        }
Ejemplo n.º 8
0
        public void Clone_SubsettingList()
        {
            var orig = new SettingsWithListOfSubsetting();

            orig.ListOfSubsetting[0].SubFieldX = 0;
            orig.ListOfSubsetting[0].SubFieldY = 1;

            var copy = SettingsPrototype.CloneAs <
                SettingsWithListOfSubsetting, SettingsWithListOfSubsetting>(orig);

            orig.ListOfSubsetting[0].SubFieldX = 10;
            orig.ListOfSubsetting[0].SubFieldY = 20;
            orig.ListOfSubsetting.Add(new SubSettingsGood());

            Assert.AreEqual(1, copy.ListOfSubsetting.Count);
            Assert.AreEqual(0, copy.ListOfSubsetting[0].SubFieldX);
            Assert.AreEqual(1, copy.ListOfSubsetting[0].SubFieldY);
        }
        public void CloneAs_CloneValuesDoNotAffectOriginal()
        {
            // arrange
            var orig = new PrintProfileFFF();

            orig.Part.Shells              = 10;
            orig.Machine.NozzleDiamMM     = 20;
            orig.Machine.ManufacturerName = "A";

            // act
            PrintProfileFFF copy = SettingsPrototype.CloneAs <PrintProfileFFF, PrintProfileFFF>(orig);

            copy.Part.Shells             *= 2;
            copy.Machine.NozzleDiamMM    *= 20;
            copy.Machine.ManufacturerName = "B";

            // assert
            Assert.AreEqual(10, orig.Part.Shells);
            Assert.AreEqual(20, orig.Machine.NozzleDiamMM);
            Assert.AreEqual("A", orig.Machine.ManufacturerName);
            Assert.AreNotSame(copy.Machine, orig.Machine);
        }
Ejemplo n.º 10
0
 public override IProfile Clone()
 {
     return(SettingsPrototype.CloneAs <MachineProfileFFF, MachineProfileFFF>(this));
 }
Ejemplo n.º 11
0
 public override IProfile Clone()
 {
     return(SettingsPrototype.CloneAs <PartProfileFFF, PartProfileFFF>(this));
 }