samedi 24 octobre 2020

DbSet.Remove() seems like to remove sometimes

Hello I have this project on Entity Framework for an exam, I have 157 test to pass and I pass 155, the last 2 are very similar to others but I dont understand why fails, I put some code so I can explain better:

 public void GetUsers_OnDeletedObject_Throws() {
            Site.Delete();
            Assert.That(() => Site.GetUsers(), Throws.TypeOf<InvalidOperationException>()); }

I defined the Delete() method to recorsively call Delete to resources in the site(like users), then remove the site from the context. From now on any method in the site must throw InvalidOperationException because the site doesn't exist anymore, but in some way Site.GetUsers() find a site and dont throw. The real mistery is if I try to insert other methods (written in same way) between the delete and the assert the extra method throw InvalidOperationException!

Aucun commentaire:

Enregistrer un commentaire