public void CanEditPersonTransaction() { using (EF_ZMT_DbContext.EF_ZMT_DbContext context = new EF_ZMT_DbContext.EF_ZMT_DbContext()) { FixedAssetService transaction = new FixedAssetService(); context.Context.ExecuteStoreCommand("DELETE FROM Person"); context.Context.ExecuteStoreCommand("DELETE FROM Section"); Section sekcja = new Section() { name = "IMZ1" }; Person person = new Person() { id = 1, name = "Jan", surname = "Kowalski", email = "*****@*****.**", Section = sekcja }; transaction.AddPerson(person); Section sekcja1 = new Section() { name = "Sekcja IMR", short_name = "IMR5" }; transaction.AddSection(sekcja1); Section sekcja_temp = context.Context.Sections.FirstOrDefault(x => x.id == sekcja.id); Assert.AreEqual(sekcja.name, sekcja_temp.name); Assert.AreEqual(context.Context.Sections.Count(), 2); Person person_temp = context.Context.People.FirstOrDefault(x => x.id == person.id); Assert.IsNotNull(person_temp); Assert.AreEqual(person_temp.id, person_temp.id); Assert.AreEqual(person_temp.name, "Jan"); Assert.AreEqual(person_temp.surname, "Kowalski"); Assert.AreEqual(person_temp.email, "*****@*****.**"); Assert.AreEqual(context.Context.People.Count(), 1); sekcja_temp = context.Context.Sections.FirstOrDefault(x => x.short_name == "IMR5"); person_temp.email = "*****@*****.**"; person_temp.surname = "Kowalczyk"; person_temp.Section = sekcja_temp; transaction.EditPerson(person_temp); Person person_temp2 = context.Context.People.FirstOrDefault(x => x.id == person.id); Assert.AreEqual(person_temp2.surname, "Kowalczyk"); Assert.AreEqual(person_temp2.email, "*****@*****.**"); Assert.AreEqual(person_temp.Section.name, "Sekcja IMR"); Assert.AreEqual(context.Context.People.Count(), 1); Assert.AreEqual(context.Context.Sections.Count(), 2); } }