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.Diagnostics.Contracts; | |
using System.Web.Http.Dependencies; | |
using Ninject; | |
using Ninject.Activation.Blocks; | |
namespace MyProject | |
{ | |
public class NinjectDependencyResolver : NinjectDependencyScope, IDependencyResolver | |
{ |
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
var ConversionStrategy = (function () { | |
function ConversionStrategy() { | |
} | |
ConversionStrategy.prototype.valueOf = function (value) { | |
return -1; | |
}; | |
return ConversionStrategy; |
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
public class StrategyQuery | |
{ | |
public string Name { get; set; } | |
} | |
public interface IStrategy | |
{ | |
bool CanHandle(StrategyQuery query); | |
void DoSomething(); | |
} |
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
describe User do | |
# The test suite adds a #stub() method to every object. Since instances of objects | |
# and class definitions are considered objects in Ruby, the #stub() method gets | |
# applied just about everywhere. It can be used to stub both instance methods and | |
# class methods. | |
it "can have tests that hit a database" do | |
user = User.find(1) # This test will go to the database | |
expect(user.username).to eq("admin") |
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
// Version 0: Nope. | |
public class SomeController | |
{ | |
public object Get(string story, string view) | |
{ | |
// Unit test blows up on the following line because there | |
// is no Request (NullReferenceException) from within a | |
// unit test. | |
var queryString = Request.RequestUri.ParseQueryString(); | |
// snip |
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
public class TryParseInt32Result | |
{ | |
private readonly bool _isSuccessful; | |
private readonly int _value; | |
public TryParseInt32Result(bool isSuccessful, int value) | |
{ | |
_isSuccessful = isSuccessful; | |
_value = 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
/** | |
* Load a collection of products from a data store. | |
* @param {array} productIds - Array of product IDs. | |
* @param {function} load - Function to load a product by ID, e.g. fetch from API, etc. | |
* @param {function} done - Done callback, to be fired when all products are loaded. | |
*/ | |
function loadProducts(productIds, load, done) { | |
// Set up vars that we will need in this function. | |
var numberOfProductIds = productIds.length; |
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
var assert = require('assert'); | |
describe('how not to make a singleton', function () { | |
var a, b; | |
beforeEach(function () { | |
a = { message: "Hello, World!" }; | |
b = { message: "Hello, World!" }; | |
}); |
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
.idea/ | |
node_modules/ | |
*.stderr | |
*.stdout |
OlderNewer