static void PrototypePattern() { Console.WriteLine("原型模式"); PersonCache.LoadCache(); Person p = PersonCache.GetPerson("1"); p.SayHi(); p = PersonCache.GetPerson("3"); p.SayHi(); }
public void RemovePerson_CountShoudbe0() { var count = PersonCache.PersonCount(); Person person = new Person(10000001, "Test", "Test"); var person2 = PersonCache.CreateUpdatePerson(person); person2 = PersonCache.GetPerson(10000001); PersonCache.RemovePerson(10000001); Assert.AreEqual(PersonCache.PersonCount(), 0); }
public void CreateUpdatePerson_AddPerson_Checkreturnperon() { var count = PersonCache.PersonCount(); Person person = new Person(10000001, "Test", "Test"); var person2 = PersonCache.CreateUpdatePerson(person); person2 = PersonCache.GetPerson(10000001); Assert.AreEqual(person2, person); Assert.AreEqual(PersonCache.PersonCount(), count + 1); }
public void CreateUpdatePerson_UpdatePerson_Checkreturnperon() { PersonCache.RemovePerson(10000001); Person person = new Person(10000001, "Test", "Test"); var person2 = PersonCache.CreateUpdatePerson(person); person.FirstName = "Test2"; person2 = PersonCache.CreateUpdatePerson(person); person2 = PersonCache.GetPerson(10000001); Assert.AreEqual(person2.FirstName, "Test2"); }