Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Xunit;
public class Fixture
{
[Fact]
public void Should_FactMethodName()
@csainty
csainty / Test.cs
Created May 18, 2012 12:08
Nancy Route Tests
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nancy;
using Nancy.Testing;
using Nancy.Testing.Fakes;
using Xunit;
using Xunit.Extensions;
public static class BootstrapperExtensions
{
public static void WithSession(this IPipelines pipeline, IDictionary<string, object> session)
{
pipeline.BeforeRequest.AddItemToEndOfPipeline(ctx =>
{
ctx.Request.Session = new Session(session);
return null;
});
}
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<iisnode loggingEnabled="false" debuggingEnabled="true" debuggerPathSegment="debug" />
<rewrite>
<rules>
<clear />
<rule name="Debug" patternSyntax="Wildcard" stopProcessing="true">
@csainty
csainty / ControllerBase.cs
Created March 22, 2012 00:50
Table query wrapper
[NonAction]
protected ActionResult WrapDataTableQuery<T>(IQueryable<T> data, Func<string, Expression<Func<T, bool>>> filter, Func<IQueryable<T>, string, bool, IOrderedQueryable<T>> applyOrderingFunction, Func<T, object[]> decorator)
{
// Fetch query parameters from the form buffer. All queries are POSTs
var queryData = ParseDataTableQueryDetails();
if (!String.IsNullOrWhiteSpace(queryData.SearchTerm))
{
data = data.Where(filter(queryData.SearchTerm.ToLower()));
}
function createPerson(name) {
var _name = name;
return {
sayHello: function () {
console.log("Hello " + _name);
}
}
}
var sue = createPerson('sue');
var bill = createPerson('bill');
// Person.js
(function () {
var Person = WinJS.Class.define(function (name) {
this.name = name;
}, {
sayHello: function () {
console.log("Hello " + this.name);
}
}, {
createPerson: function (name) {
var Person = (function() {
var ctor = function(name) {
var _name = name;
this.get_name = function() { return _name; } // Wrap the private variable with a getter
};
ctor.prototype.sayHello = function () {
console.log("Hello " + this.get_name());
}
var Person = function (name) {
this.name = name;
};
Person.prototype.sayHello = function () {
console.log("Hello " + this.name);
}
var sue = new Person('sue');
sue.sayHello(); // prints Hello sue
var bill = new Person('bill');
function createPerson(name) {
return {
name: name,
sayHello: function () {
console.log("Hello " + this.name);
}
}
}
var sue = createPerson('sue');
var bill = createPerson('bill');