示例#1
0
        public void TestMementoFormList()
        {
            Dictionary <string, Form> Dictionary = new Dictionary <string, Form>();

            Dictionary.Add("N1", new Form()
            {
                Name = "Name1", LastName = "Last1"
            });
            Dictionary.Add("N2", new Form()
            {
                Name = "Name2", LastName = "Last2"
            });
            Dictionary.Add("N3", new Form()
            {
                Name = "Name3", LastName = "Last3"
            });

            Assert.AreEqual(Dictionary["N1"].Name, "Name1");

            Dictionary["N1"] = Dictionary["N2"];

            Assert.AreEqual(Dictionary["N1"].Name, "Name2");

            Form FormClone = MementoForm.GetNewForm(Dictionary["N1"]);

            Dictionary["N1"] = FormClone;
            FormClone.Name   = "Name55";

            Assert.AreEqual(FormClone.Name, "Name55");
        }
示例#2
0
        public void TestMementoForm()
        {
            Form Form = new Form();

            Form.Name     = "Name";
            Form.LastName = "Last";
            Form.Resume   = "Resu";
            Form.Created  = DateTime.Now;

            Form New = MementoForm.GetNewForm(Form);

            New.Name = "Name3";

            Assert.AreEqual(Form.Name, "Name");
            Assert.AreEqual(New.Name, "Name3");
        }
        private void MementoPatternBtn_Click(object sender, EventArgs e)
        {
            Form mementoPattern = new MementoForm();

            mementoPattern.Show();
        }