This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of usage | |
[TestMethod] | |
[AspNetDevelopmentServer("WcfService", "Physical path to your WCF project")] | |
public void TestMethod1() | |
{ | |
ServiceClient target = new ServiceClient(); | |
Assert.IsTrue(WcfWebServiceHelper.TryUrlRedirection(target, TestContext, "WcfService")); | |
int value = 0; | |
string expected = "You entered: 0"; | |
string actual; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void SetupControllerForTests(ApiController controller, string controllerName) | |
{ | |
var config = new HttpConfiguration(); | |
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/" + controllerName); | |
var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}"); | |
var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", controllerName } }); | |
controller.ControllerContext = new HttpControllerContext(config, routeData, request); | |
controller.Request = request; | |
controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using Moq; | |
namespace TestDoubles.Examples.Dummy | |
{ | |
[TestClass] | |
public class Player_Test | |
{ | |
[TestMethod] | |
public void Should_be_able_to_roll_die_wtih_max_face_value() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using Moq; | |
namespace TestDoubles.Examples.Stub | |
{ | |
[TestClass] | |
public class Player_Test | |
{ | |
[TestMethod] | |
public void Should_be_able_to_roll_die_wtih_max_face_value() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using Moq; | |
namespace TestDoubles.Examples.Mock | |
{ | |
[TestClass] | |
public class Player_Test | |
{ | |
[TestMethod] | |
public void Should_be_able_to_roll_die_wtih_max_face_value() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace TestDoubles.Examples.Fake | |
{ | |
[TestClass] | |
public class Invoice_Test | |
{ | |
[TestMethod] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using Moq; | |
namespace TestDoubles.Examples.TestSpecificSubclass.ProtectedMember | |
{ | |
[TestClass] | |
public class Player_Test | |
{ | |
[TestMethod] | |
public void Should_be_able_to_roll_die_wtih_max_face_value() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void $MethodUnderTest$_should_$EXPECTED_BEHAVIOR$() | |
{ | |
// Arrange | |
$END$ | |
// Act | |
// Assert | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
namespace Nullable | |
{ | |
public class Nullable_Test | |
{ | |
public void SumNullableNumbers() | |
{ | |
int?[] numbers = new int?[10]; | |
int sum = numbers.Where(n => n.HasValue).Sum(n => n.Value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
namespace ConsoleApplication1 | |
{ | |
public class AssemblyGenerator | |
{ | |
public static ModuleBuilder CreateModuleBuilder(Action<ModuleBuilder> buildTypes, string assemblyName) | |
{ |
OlderNewer