Gaskets are typically used to provide mocks from assemblies outside your solution, while stubs are used to create class mockups in your solution.
Stub example
// Create the fake calculator: ICalculator calculator = new Calculator.Fakes.StubICalculator() { // Define each method: Add = (a,b) => { return 25; } };
Gasket Example
//Using shims to control the response to DateTime.Now using (ShimsContext.Create()) { // insert the delegate that returns call for DateTime.Now System.Fakes.ShimDateTime.NowGet = () => new DateTime(2010, 1, 1); MethodThatUsesDateTimeNow(); }
Courtesy: Exam No. 70-486
Deepak mishra
source share