I have partial code coverage and I don't know why. for people who like the question before they start reading
Want to start by saying "First Post" as well as I am still very Junior in my development career but I have been a relativly quick learner(imo), so here it goes. Using Nunit to test, and MVP based.
Code to be tested -
void _view_Delete(object sender, EventArgs<Guid> e)
{
_agRepo.Delete(_agRepo.GetByID(e.Value));
var g = _agRepo.GetAll();
if (g.Count() > 0)
{
_view.FillRelatableAccessGroups(g.Where(x => x.IsRelatable));//partial coverage
_view.FillStandAloneAccessGroups(g.Where(x => !x.IsRelatable));//partial coverage
}
else
{
_view.ShowErrorMsg(true, "No Access Groups Found.");
}
}
The code that is testing the 'if' and the 'else' statements(assuming the repo and view are mocked)-
[Test]
public void TestDelete()
{
_view.Raise(v => v.Delete += null, this, new EventArgs<Guid>(1.ToGuid()));
_agRepo.AssertWasCalled(r => r.Delete(_agRepo.GetByID(1.ToGuid())));
_view.AssertWasCalled(v => v.FillRelatableAccessGroups(Arg<IEnumerable<AccessGroup>>.Is.Anything));
_view.AssertWasCalled(v => v.FillStandAloneAccessGroups(Arg<IEnumerable<AccessGroup>>.Is.Anything));
}
[Test]
public void TestDeleteNoGroups()
{
_agList.Clear();
_view.Raise(v => v.Delete += null, this, new EventArgs<Guid>(1.ToGuid()));
_agRepo.AssertWasCalled(r => r.Delete(_agRepo.GetByID(1.ToGuid())));
_view.AssertWasNotCalled(v => v.FillRelatableAccessGroups(Arg<IEnumerable<AccessGroup>>.Is.Anything));
_view.AssertWasNotCalled(v => v.FillStandAloneAccessGroups(Arg<IEnumerable<AccessGroup>>.Is.Anything));
_view.AssertWasCalled(x => x.ShowErrorMsg(true, "No Access Groups Found."));
}
So my question is, what I am missing in my code. Something more is going on that I need to test and I really would like to find it. I have been heads down in trying to fully understand the in's and out's of testing. Test Driven Development is my goal. If anyone has any kind of input (good or bad) it would be very much appreciated. I wouldn't even mind if someone could throw me juuuuuuuust enough so I can start pulling on that metophorical string that has the answer I am looking for tied to the end of it. I hope I have provided enough information for you all. Thanks!