root/trunk/Experiment/UsingMoQ/UsingMoQ/Program.cs

Revision 7, 1.0 kB (checked in by louis.dejardin, 9 months ago)

Using MoQ - it's very nice

Line 
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Moq;
6
7
8 namespace UsingMoQ
9 {
10     class Program
11     {
12         static void Main(string[] args)
13         {
14             var cruncher = new Mock<ICruncher>();
15
16             cruncher.Expect(x => x.Add(2, 4)).Returns(6);
17             cruncher.Expect(yyy => yyy.Add(5, 2)).Returns(3);
18
19             int twoPlusFour = cruncher.Object.Add(2, 4);
20             int fivePlusTwo = cruncher.Object.Add(5, 2);
21             Console.WriteLine("twoPlusFour = {0}, fivePlusTwo = {1}", twoPlusFour, fivePlusTwo);
22
23             try
24             {
25                 int onePlusOne = cruncher.Object.Add(1, 1);
26                 Console.WriteLine("onePlusOne = {0}", onePlusOne);
27             }
28             catch (Exception ex)
29             {
30                 Console.WriteLine(ex.Message);
31             }
32            
33             Console.WriteLine("Press enter to exit");
34             Console.ReadLine();
35         }
36     }
37 }
Note: See TracBrowser for help on using the browser.