Note that there are some explanatory texts on larger screens.

plurals
  1. POQuestions about TDD
    text
    copied!<h2>Environment</h2> <p>In my solution I have three projects, they are:</p> <ol> <li>Web (Asp.net MVC4)</li> <li>Model (Class library)</li> <li>Test (Test project)</li> </ol> <p>In <strong>Model project</strong> have:</p> <p><code>Couple</code> = Class</p> <p><code>IRepository</code> = Interface-based repository</p> <p><code>ICoupleRepository</code> = Interface Repository couple</p> <p><code>Implementation</code> repository = CoupleRepository couple</p> <p>In <strong>Test project</strong> have:</p> <p>Fake/<code>CoupleRepository</code> = Fake implementation of Repository couple (inside the folder Fake). <code>CoupleTest</code> couple class = Test</p> <h2>Behavior</h2> <p>By adding a couple under, need to modify some properties and also add a couple object also add other objects to the database.</p> <p>I put this logic into the <code>CoupleRepository</code> (not fake) repository in <code>Add</code> method, I set these properties, add the object couple and two other objects.</p> <pre><code>public class CoupleRepository : ICoupleRepository { public void Add(Couple couple) { couple.Bride.Gender = Gender.Female; couple.Groom.Gender = Gender.Male; db.Couples.Add(couple); db.Users.Add(new User{ CoupleID = couple.Bride.ID }); db.Users.Add(new User{ CoupleID = couple.Groom.ID }); db.SaveChanges(); } } </code></pre> <h2>Question</h2> <p>In my test class, <code>CoupleTest</code>, need to test the addition of these users as well, and the modification of the properties.</p> <p>Create a fake repository for my forehead it will not help me, really need to test code that is in default CoupleRepository.</p> <p>What is the <strong>tip you give me</strong>?</p> <p>Where <strong>Mocks and Stubs come in all this?</strong></p> <p>Where <strong>would this logic to save a couple?</strong></p> <p>I have to test repositories? Perhaps the ideal would be to <strong>test the controllers?</strong></p> <p>Many questions, I know =)</p> <hr> <p>I'm new to TDD and do not know if I'm going in the right direction.</p> <p>Test the default repository would not be ideal, since it accesses the database.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload