public void TwoChildren_OneAllParentsRemoved_ViaRemoveChild_ValidatesAsExpected() { //arrange var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("marge", "Simpson"); var child1 = new UIPerson("Lisa", "Simpson"); var child2 = new UIPerson("Rod", "Flanders"); this.GenealogyMasterModel.AddPerson(father); this.GenealogyMasterModel.AddPerson(mother); this.GenealogyMasterModel.AddPerson(child1); this.GenealogyMasterModel.AddPerson(child2); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child1); this.GenealogyMasterModel.ChildRelationmanager.AddChild(mother, child1); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child2); this.GenealogyMasterModel.ChildRelationmanager.AddChild(mother, child2); //act this.GenealogyMasterModel.ChildRelationmanager.RemoveChild(father, child2); this.GenealogyMasterModel.ChildRelationmanager.RemoveChild(mother, child2); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(father.Children.Count, 1); Assert.AreEqual(mother.Children.Count, 1); Assert.AreEqual(child1.Parents.Count, 2); Assert.AreEqual(father.Partners.Count, 1); Assert.AreEqual(mother.Partners.Count, 1); }
public void InvalidState_AddThirdParent_ViaAddParent() { var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson"); var child1 = new UIPerson("Bart", "Simpson"); var child2 = new UIPerson("Lisa", "Simpson"); var bitch = new UIPerson("Bitch", "Samson"); this.GenealogyMasterModel.AddPerson(father); this.GenealogyMasterModel.AddPerson(mother); this.GenealogyMasterModel.AddPerson(child1); this.GenealogyMasterModel.AddPerson(child2); this.GenealogyMasterModel.AddPerson(bitch); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child1); this.GenealogyMasterModel.ChildRelationmanager.AddChild(mother, child1); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child2); this.GenealogyMasterModel.ChildRelationmanager.AddChild(mother, child2); this.GenealogyMasterModel.ParentRelationManager.AddParent(child1, bitch); //the invalid one var persons = this.GenealogyMasterModel.GetAll(); }
public void SimplePerson_Serialization_Deserialization_PropertyEqualityCheck() { //arrange var genealogyMaster = new GenealogyMaster(); var person = new UIPerson("Firstname", "Lastname"); person.IsFemale = true; person.Biography = "My super biography"; person.IsHidden = true; person.DateOfBirth = new DateTime(1990, 12, 10); person.DateOfDeath = new DateTime(1990, 12, 12); //act genealogyMaster.AddPerson(person); var restoredPersons = this.SerializeThenDeserializePersons(genealogyMaster.GetAll()); //assert var restoredPerson = restoredPersons.SingleOrDefault(); Assert.AreEqual(1, restoredPersons.Count); Assert.AreEqual(person.FirstName, restoredPerson.FirstName); Assert.AreEqual(person.LastName, restoredPerson.LastName); Assert.AreEqual(person.IsFemale, restoredPerson.IsFemale); Assert.AreEqual(person.Biography, restoredPerson.Biography); Assert.AreEqual(person.IsHidden, restoredPerson.IsHidden); Assert.AreEqual(person.DateOfBirth, restoredPerson.DateOfBirth); Assert.AreEqual(person.DateOfDeath, restoredPerson.DateOfDeath); }
public async Task GranpaGranmaFatherMotherSon() { var filename = "granpaGranmaHomerMargeAndBart.png"; var renderFormat = RendererFormats.Png; var granpa = new UIPerson("Abraham", "Simpson"); var granma = new UIPerson("Mona", "Simpson"); var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson"); var child1 = new UIPerson("Bart", "Simpson"); this.GenealogyMaster.AddPerson(mother); this.GenealogyMaster.AddPerson(father); this.GenealogyMaster.ChildRelationmanager.AddChild(mother, child1); this.GenealogyMaster.ChildRelationmanager.AddChild(father, child1); this.GenealogyMaster.ParentRelationManager.AddParent(father, granpa); this.GenealogyMaster.ParentRelationManager.AddParent(father, granma); var persons = this.GenealogyMaster.GetAll(); await this.GenealogyVisualizerModel.WriteFile(persons, filename, renderFormat, false); Assert.IsTrue(File.Exists(Path.GetFileNameWithoutExtension(filename) + "." + renderFormat)); Process.Start(Path.GetFileNameWithoutExtension(filename) + "." + renderFormat); }
public void FamilyWithTwoChildren_OneChildPersonRemoved_LinksChildrenToParentsAccordingly() { //arrange var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson"); var child1 = new UIPerson("Bart", "Simpson"); var child2 = new UIPerson("Lisa", "Simpson"); this.GenealogyMasterModel.AddPerson(father); this.GenealogyMasterModel.AddPerson(mother); this.GenealogyMasterModel.AddPerson(child1); this.GenealogyMasterModel.AddPerson(child2); this.GenealogyMasterModel.ChildRelationmanager.AddChild(mother, child1); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child1); this.GenealogyMasterModel.ChildRelationmanager.AddChild(mother, child2); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child2); //act this.GenealogyMasterModel.RemovePerson(child2); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(3, persons.Count); Assert.AreEqual(1, father.Children.Count); Assert.AreEqual(1, mother.Children.Count); Assert.AreEqual(2, child1.Parents.Count); }
public void FamilyWithBastard_AddChild_LinksChildrenToParentsAccordingly() { //arrange var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson"); var child = new UIPerson("Bart", "Simpson"); var bitch = new UIPerson("Bitch", "Samson"); var bastard = new UIPerson("Bastard", "Samson"); this.GenealogyMasterModel.AddPerson(father); this.GenealogyMasterModel.AddPerson(mother); this.GenealogyMasterModel.AddPerson(child); this.GenealogyMasterModel.AddPerson(bitch); this.GenealogyMasterModel.AddPerson(bastard); //act this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child); this.GenealogyMasterModel.ChildRelationmanager.AddChild(mother, child); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, bastard); this.GenealogyMasterModel.ChildRelationmanager.AddChild(bitch, bastard); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(5, persons.Count); Assert.AreEqual(2, father.Children.Count); Assert.AreEqual(1, mother.Children.Count); Assert.AreEqual(1, bitch.Children.Count); Assert.AreEqual(2, child.Parents.Count); Assert.AreEqual(2, bastard.Parents.Count); }
public void RemoveOneParent_UnLinksImplicitPartner() { //arrange var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson"); var child = new UIPerson("Bart", "Simpson"); this.GenealogyMasterModel.AddPerson(child); this.GenealogyMasterModel.AddPerson(father); this.GenealogyMasterModel.AddPerson(mother); this.GenealogyMasterModel.ParentRelationManager.AddParent(child, father); this.GenealogyMasterModel.ParentRelationManager.AddParent(child, mother); //act this.GenealogyMasterModel.RemovePerson(mother); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(2, persons.Count); Assert.AreEqual(1, child.Parents.Count); Assert.AreEqual(0, child.Children.Count); Assert.AreEqual(1, father.Children.Count); Assert.AreEqual(0, mother.Children.Count); Assert.AreEqual(0, father.Parents.Count); Assert.AreEqual(0, mother.Parents.Count); Assert.AreEqual(0, father.Partners.Count); Assert.AreEqual(0, mother.Partners.Count); }
public void RemovePersonLinkedAsChild_UnLinksImplicitPartner() { //arrange var parentHusband = new UIPerson("Homer", "Simpson"); var parentWife = new UIPerson("Marge", "Simpson"); var child = new UIPerson("Bart", "Simpson"); this.GenealogyMasterModel.AddPerson(child); this.GenealogyMasterModel.AddPerson(parentHusband); this.GenealogyMasterModel.AddPerson(parentWife); this.GenealogyMasterModel.ChildRelationmanager.AddChild(parentHusband, child); this.GenealogyMasterModel.ChildRelationmanager.AddChild(parentWife, child); //act this.GenealogyMasterModel.RemovePerson(child); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(2, persons.Count); Assert.AreEqual(0, parentHusband.Children.Count); Assert.AreEqual(0, parentWife.Children.Count); Assert.AreEqual(0, parentHusband.Parents.Count); Assert.AreEqual(0, parentWife.Parents.Count); Assert.AreEqual(0, parentHusband.Partners.Count); Assert.AreEqual(0, parentWife.Partners.Count); }
public void AddParents_LinksImplicitPartner() { //arrange var parentHusband = new UIPerson("Homer", "Simpson"); var parentWife = new UIPerson("Marge", "Simpson"); var child = new UIPerson("Bart", "Simpson"); this.GenealogyMasterModel.AddPerson(child); this.GenealogyMasterModel.AddPerson(parentHusband); this.GenealogyMasterModel.AddPerson(parentWife); //act this.GenealogyMasterModel.ParentRelationManager.AddParent(child, parentHusband); this.GenealogyMasterModel.ParentRelationManager.AddParent(child, parentWife); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(3, persons.Count); Assert.AreEqual(2, child.Parents.Count); Assert.AreEqual(0, child.Children.Count); Assert.AreEqual(1, parentHusband.Children.Count); Assert.AreEqual(1, parentWife.Children.Count); Assert.AreEqual(0, parentHusband.Parents.Count); Assert.AreEqual(0, parentWife.Parents.Count); Assert.AreEqual(1, parentHusband.Partners.Count); Assert.AreEqual(1, parentWife.Partners.Count); Assert.AreEqual(parentHusband.Partners[0], parentWife); Assert.AreEqual(parentWife.Partners[0], parentHusband); }
private void AddPersonMethod() { var coolGuy = new UIPerson(this.FirstName, this.LastName); this.Persons.Add(coolGuy); this.FirstName = string.Empty; }
public AddData() { InitializeComponent(); uiSaveData.Save.Click += Save_Click; uiSaveData.RefreshAll.Click += Refresh_Click; uiSaveData.Cancel.Click += Cancel_Click; TabChanged += Tab_Changed; uIPerson = new UIPerson(); uIVendor = new UIVendor(); uIUser = new UIUser(); }
public void AddPersonTwice_AddedJustOnce() { //arrange //act var personInstance = new UIPerson("Lonely", "Guy"); this.GenealogyMasterModel.AddPerson(personInstance); this.GenealogyMasterModel.AddPerson(personInstance); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(1, persons.Count); }
public async Task FatherAndSon() { var filename = "homerAndBart.png"; var parent = new UIPerson("Homer", "Simpson"); parent.DateOfBirth = new DateTime(1990, 12, 10); parent.DateOfDeath = new DateTime(1990, 12, 12); this.GenealogyMaster.AddPerson(parent); this.GenealogyMaster.ChildRelationmanager.AddChild(parent, new UIPerson("Bart", "Simpson")); await this.GenealogyVisualizerModel.WriteFile(this.GenealogyMaster.GetAll(), filename, RendererFormats.Png, false); Assert.IsTrue(File.Exists(filename)); Process.Start(filename); }
public void InvalidState_GrandsonAlsoSon_ViaAddParent() { var father = new UIPerson("Homer", "Simpson"); var child = new UIPerson("Bart", "Simpson"); var granpa = new UIPerson("Abraham", "Simpson"); this.GenealogyMasterModel.AddPerson(father); this.GenealogyMasterModel.AddPerson(child); this.GenealogyMasterModel.AddPerson(granpa); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child); this.GenealogyMasterModel.ChildRelationmanager.AddChild(granpa, father); this.GenealogyMasterModel.ParentRelationManager.AddParent(child, granpa); //invalid var persons = this.GenealogyMasterModel.GetAll(); }
public void InvalidState_AddChildAsParent_ViaAddParent() { var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson"); var child = new UIPerson("Bart", "Simpson"); this.GenealogyMasterModel.AddPerson(father); this.GenealogyMasterModel.AddPerson(mother); this.GenealogyMasterModel.AddPerson(child); this.GenealogyMasterModel.ChildRelationmanager.AddChild(father, child); this.GenealogyMasterModel.ChildRelationmanager.AddChild(mother, child); this.GenealogyMasterModel.ParentRelationManager.AddParent(father, child); //child with parent as child invalid var persons = this.GenealogyMasterModel.GetAll(); }
public async Task FamilyWith3Kids_WithBastard_ThenDisproven_NotFromFather() { var filename = "familyWithBastard_disproven.png"; var renderFormat = RendererFormats.Png; var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson"); var child1 = new UIPerson("Bart", "Simpson"); var child2 = new UIPerson("Lisa", "Simpson"); var child3 = new UIPerson("Maggie", "Simpson"); var bitch = new UIPerson("Bitch", "Samson"); var bastard = new UIPerson("Bastard", "Samson"); this.GenealogyMaster.AddPerson(father); this.GenealogyMaster.AddPerson(mother); this.GenealogyMaster.AddPerson(child1); this.GenealogyMaster.AddPerson(child2); this.GenealogyMaster.AddPerson(child3); this.GenealogyMaster.AddPerson(bitch); this.GenealogyMaster.AddPerson(bastard); this.GenealogyMaster.ChildRelationmanager.AddChild(father, child1); this.GenealogyMaster.ChildRelationmanager.AddChild(mother, child1); this.GenealogyMaster.ChildRelationmanager.AddChild(father, child2); this.GenealogyMaster.ChildRelationmanager.AddChild(mother, child2); this.GenealogyMaster.ChildRelationmanager.AddChild(father, child3); this.GenealogyMaster.ChildRelationmanager.AddChild(mother, child3); this.GenealogyMaster.ChildRelationmanager.AddChild(father, bastard); this.GenealogyMaster.ChildRelationmanager.AddChild(bitch, bastard); this.GenealogyMaster.ChildRelationmanager.RemoveChild(father, bastard); //not his bastard var persons = this.GenealogyMaster.GetAll(); await this.GenealogyVisualizerModel.WriteFile(persons, filename, renderFormat, false); Assert.IsTrue(File.Exists(Path.GetFileNameWithoutExtension(filename) + "." + renderFormat)); Process.Start(Path.GetFileNameWithoutExtension(filename) + "." + renderFormat); }
public void AddParent_LinksParentAndChildAccordingly() { //arrange var parent = new UIPerson("Homer", "Simpson"); var child = new UIPerson("Bart", "Simpson"); this.GenealogyMasterModel.AddPerson(child); this.GenealogyMasterModel.AddPerson(parent); //act this.GenealogyMasterModel.ParentRelationManager.AddParent(child, parent); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(2, persons.Count); Assert.AreEqual(1, child.Parents.Count); Assert.AreEqual(0, child.Children.Count); Assert.AreEqual(1, parent.Children.Count); Assert.AreEqual(0, parent.Parents.Count); }
public async Task FatherMotherAndThreeChildren() { var filename = "homerMargeBartLisaMaggie.png"; var renderFormat = RendererFormats.Png; var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson") { IsFemale = true }; var child1 = new UIPerson("Bart", "Simpson"); var child2 = new UIPerson("Lisa", "Simpson") { IsFemale = true }; var child3 = new UIPerson("Maggie", "Simpson") { IsFemale = true }; this.GenealogyMaster.AddPerson(father); this.GenealogyMaster.AddPerson(mother); this.GenealogyMaster.ChildRelationmanager.AddChild(father, child1); this.GenealogyMaster.ChildRelationmanager.AddChild(mother, child1); this.GenealogyMaster.ChildRelationmanager.AddChild(father, child2); this.GenealogyMaster.ChildRelationmanager.AddChild(mother, child2); this.GenealogyMaster.ChildRelationmanager.AddChild(father, child3); this.GenealogyMaster.ChildRelationmanager.AddChild(mother, child3); var persons = this.GenealogyMaster.GetAll(); await this.GenealogyVisualizerModel.WriteFile(persons, filename, renderFormat, false); Assert.IsTrue(File.Exists(Path.GetFileNameWithoutExtension(filename) + "." + renderFormat)); Process.Start(Path.GetFileNameWithoutExtension(filename) + "." + renderFormat); }
public void AddChildTwice_AddedJustOnce() { //arrange var parent = new UIPerson("Homer", "Simpson"); var child = new UIPerson("Bart", "Simpson"); this.GenealogyMasterModel.AddPerson(child); this.GenealogyMasterModel.AddPerson(parent); //act this.GenealogyMasterModel.ChildRelationmanager.AddChild(parent, child); this.GenealogyMasterModel.ChildRelationmanager.AddChild(parent, child); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(2, persons.Count); Assert.AreEqual(1, child.Parents.Count); Assert.AreEqual(0, child.Children.Count); Assert.AreEqual(1, parent.Children.Count); Assert.AreEqual(0, parent.Parents.Count); }
public void PersonWithParent_Serialization_Deserialization_PropertyEqualityCheck() { //arrange var genealogyMaster = new GenealogyMaster(); var child = new UIPerson("Bart", "Simpson"); var parent = new UIPerson("Marge", "Simpson"); genealogyMaster.AddPerson(parent); genealogyMaster.AddPerson(child); //act genealogyMaster.ParentRelationManager.AddParent(child, parent); var restoredPersons = this.SerializeThenDeserializePersons(genealogyMaster.GetAll()); //assert var restoredChild = restoredPersons.FirstOrDefault(x => x.FirstName == "Bart"); Assert.AreEqual(2, restoredPersons.Count); Assert.AreEqual(1, restoredChild.Parents.Count); Assert.AreEqual(0, restoredChild.Children.Count); Assert.AreEqual(1, restoredChild.Parents[0].Children.Count); Assert.AreEqual(0, restoredChild.Parents[0].Parents.Count); }
public void SwapPositions() { //arrange var personPos1 = new UIPerson("ShouldBeSecond", "Guy"); var personPos2 = new UIPerson("ShouldBeFirst", "Guy"); this.GenealogyMasterModel.AddPerson(personPos1); this.GenealogyMasterModel.AddPerson(personPos2); var personsBefore = this.GenealogyMasterModel.GetAll(); Assert.AreNotEqual(personsBefore[0].FirstName, "ShouldBeFirst"); Assert.AreNotEqual(personsBefore[1].FirstName, "ShouldBeSecond"); //act this.GenealogyMasterModel.Swap(1, 0); //assert var persons = this.GenealogyMasterModel.GetAll(); Assert.AreEqual(persons[0].FirstName, "ShouldBeFirst"); Assert.AreEqual(persons[1].FirstName, "ShouldBeSecond"); }
public AddData(PersonType personType, uint ID = 0) { InitializeComponent(); uiSaveData.Save.Click += Save_Click; uiSaveData.RefreshAll.Click += Refresh_Click; uiSaveData.Cancel.Click += Cancel_Click; TabChanged += Tab_Changed; if (ID != 0) { Edit = true; uIPerson = new UIPerson(); uIVendor = new UIVendor(); uIUser = new UIUser(ID); } else { uIPerson = new UIPerson(); uIVendor = new UIVendor(); uIUser = new UIUser(); } Current = personType; }
public async Task SvgWorks() { var filename = "homerMargeAndBart.svg"; var renderFormat = RendererFormats.Svg; var father = new UIPerson("Homer", "Simpson"); var mother = new UIPerson("Marge", "Simpson") { IsFemale = true }; var child = new UIPerson("Bart", "Simpson"); this.GenealogyMaster.AddPerson(father); this.GenealogyMaster.AddPerson(mother); this.GenealogyMaster.ChildRelationmanager.AddChild(father, child); this.GenealogyMaster.ChildRelationmanager.AddChild(mother, child); var persons = this.GenealogyMaster.GetAll(); await this.GenealogyVisualizerModel.WriteFile(persons, filename, renderFormat, false); Assert.IsTrue(File.Exists(Path.GetFileNameWithoutExtension(filename) + "." + renderFormat)); Process.Start(Path.GetFileNameWithoutExtension(filename) + "." + renderFormat); }
public void IdGenerator_1000People_NoDuplicates() { //arrange //act for (int i = 0; i < 999; i++) { var person = new UIPerson("FirstName", "LastName"); this.GenealogyMasterModel.AddPerson(person, false); } //assert var people = this.GenealogyMasterModel.GetAll(); var peopleIds = people.Select(x => x.Id); var distinct = people.GroupBy(person => person.Id).Select(g => g.First()).ToList(); var distinctCount = distinct.Count; var duplicates = people.Except(distinct); var duplicatesCount = duplicates.Count(); Assert.AreEqual(999, peopleIds.Count()); Assert.AreEqual(999, distinctCount); Assert.AreEqual(0, duplicatesCount); }