Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Your
Code
Test
[TestMethod]
public void Method_Scenario_Result()
{
// Set dependencies, build SUT, set
// expectations
// Exercise the SU...
[TestMethod]
public void Method_Scenario_Result()
{
// Set dependencies, build SUT, set
// expectations
// Exercise the SU...
[Test]
public void CreateNumString_TwoSimpleNumbers_ReturnsStringWithCommaBetween()
{
StringCalc sc = new StringCalc();
st...
SUT Dependancy
Dependancy
Dependency
public class Sample{
private DatabaseThingie myDatabase;
public Sample() {
myDatabase = new DatabaseThingie();
}
public vo...
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Unit Testing and Mocking using MOQ
Prochain SlideShare
Chargement dans…5
×

Unit Testing and Mocking using MOQ

1 779 vues

Publié le

A brief description of unit testing, with a more thorough walkthrough of how to mock using MOQ. The demo code can be found at http://1drv.ms/1kQJWhb

Publié dans : Technologie, Formation
  • Soyez le premier à commenter

Unit Testing and Mocking using MOQ

  1. 1. Your Code Test
  2. 2. [TestMethod] public void Method_Scenario_Result() { // Set dependencies, build SUT, set // expectations // Exercise the SUT // Check behaviour/state of SUT // Check that expectations have been met } Assert Act Arrange
  3. 3. [TestMethod] public void Method_Scenario_Result() { // Set dependencies, build SUT, set // expectations // Exercise the SUT // Check behaviour/state of SUT // Check that expectations have been met } Assert Act Arrange
  4. 4. [Test] public void CreateNumString_TwoSimpleNumbers_ReturnsStringWithCommaBetween() { StringCalc sc = new StringCalc(); string result = sc.CreateNumString(1, 2); Assert.AreEqual(String.Format("{0},{1}", x, y), result); }
  5. 5. SUT Dependancy Dependancy Dependency
  6. 6. public class Sample{ private DatabaseThingie myDatabase; public Sample() { myDatabase = new DatabaseThingie(); } public void DoStuff() { myDatabase.GetData(); } }

×