i have a a piece of code I would like to refactor. I have an idea, but I am not sure how to execute the idea.
I would also like you to validate the idea.
So let's suppose I have a few tests, and they are all very similar. The only difference is in Asserts to a collection.
To get to that collection I need to go through multiple nested loops. Say 3 nested loops.
[Test]
public void ShouldBeATest()
{
foreach()
{
foreach()
{
foreach()
{
var collection = new Collection();
Assert.Something(collection.Any(c => c.something == 'good')); // this part changes only.
}
}
}
}
How should I go about refactoring? I wanted to extract most of the code to a method, and pass to it different functions that would perform Asserts. Does it make any sense?
Regards
Aucun commentaire:
Enregistrer un commentaire