I am attempting to unit test a PUT Request by checking values. However, I run into one simple issue. I have a test context like such:
class TestAppContext : ContextInterface
{
public DbSet<User> Users {get; set;}
public DbSet<Request> Requests { get; set; }
public TestAppContext()
{
this.Users = new TestUsersDbSet();
this.Requests = new TestRequestsDbSet();
}
public int SaveChanges(){
return 0;
}
public void MarkAsModified(Object item) {
}
public void Dispose() { }
}
}
When running a PUT with a DbContext the Entry(item).State
is set to EntityState.Modified
in the MarkAsModified
method, then changes the changes are saved. How do I emulate this in my test context so that the DbSet reflects the changes from the PUT request?
I've gotten as far as doing this:
public void MarkAsModified(Object item) {
if (item.GetType() == typeof(User))
{
}
else if (item.GetType() == typeof(Request))
{
}
}
So that I can determine what is being modified, but how do I actually save the changes into the DbSet for that record?
Both records are identified on a variable id
which is an int
.
Aucun commentaire:
Enregistrer un commentaire