Exemplo n.º 1
0
        public void CopyFromSameType_Field_ValueType()
        {
            var orig = new SettingsA();
            var copy = new SettingsA();

            orig.IntegerFieldA = 3;

            SettingsPrototype.CopyValuesFrom(copy, orig);

            Assert.AreEqual(3, copy.IntegerFieldA);
        }
        public void CloneAs_SiblingClass()
        {
            // arrange
            var orig = MachineProfilesFactoryFFF.Prusa.Create_i3Mk3();

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

            // assert
            Assert.IsNotNull(clone);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void CopyFromSibling_Field_ValueType()
        {
            var orig = new SettingsB();
            var copy = new SettingsC();

            orig.IntegerFieldA = 9;

            SettingsPrototype.CopyValuesFrom(copy, orig);

            Assert.AreEqual(9, copy.IntegerFieldA);
        }
Exemplo n.º 5
0
        public void CopyFromSameType_Property_ValueType()
        {
            var orig = new SettingsA();
            var copy = new SettingsA();

            orig.IntegerPropertyA = 5;

            SettingsPrototype.CopyValuesFrom(copy, orig);

            Assert.AreEqual(5, copy.IntegerPropertyA);
        }
Exemplo n.º 6
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]);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public void Clone_FieldsWithSameEnums()
        {
            var orig = new SettingsF();

            orig.Enum = EnumNumbers.One;

            var copy = new SettingsF();

            copy.Enum = EnumNumbers.Two;

            SettingsPrototype.CopyValuesFrom(copy, orig);

            Assert.AreEqual(EnumNumbers.One, copy.Enum);
        }
Exemplo n.º 10
0
        public void Clone_FieldsWithDifferentEnums()
        {
            var orig = new SettingsF();

            orig.Enum = EnumNumbers.One;

            var copy = new SettingsG();

            copy.Enum = EnumColors.Red;

            SettingsPrototype.CopyValuesFrom(copy, orig);

            Assert.AreEqual(EnumColors.Red, copy.Enum);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 15
0
 public override IProfile Clone()
 {
     return(SettingsPrototype.CloneAs <MachineProfileFFF, MachineProfileFFF>(this));
 }
Exemplo n.º 16
0
 public override IProfile Clone()
 {
     return(SettingsPrototype.CloneAs <PartProfileFFF, PartProfileFFF>(this));
 }