Skip to content

Instantly share code, notes, and snippets.

private void SetupFakeNancyCompleteCallback(NancyContext context)
{
A.CallTo(() => this.fakeEngine.HandleRequest(A<Request>.Ignored, A<Func<NancyContext, NancyContext>>.Ignored, A<Action<NancyContext>>.Ignored, A<Action<Exception>>.Ignored))
.Invokes((i => ((Action<NancyContext>)i.Arguments[2]).Invoke(context)));
}
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/Scripts/jquery")
.Include("~/assets/javascripts/vendors/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/Scripts/app")
.IncludeFromSprocketFile("~/assets/javascripts/main.js"));
var templateBundle = new Bundle("~/Scripts/templates").IncludeDirectory("~/assets/templates", "*.html");
templateBundle.Transforms.Add(new HtmlBundleTransform());
namespace NancySample.Backbone.Todos
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Cassette;
using Cassette.BundleProcessing;
// current implementation of JavaScriptHtmlTemplatePipeline
(function(d) {
var addTemplate = function(id, content) {
var script = d.createElement('script');
script.type = 'text/html';
script.id = id;
if (typeof script.textContent !== 'undefined') {
script.textContent = content;
} else {
if (string.IsNullOrWhiteSpace(context.ModulePath))
return null;
if (viewName.StartsWith("~/"))
return viewName.Substring(2);
return string.Concat("Views/", context.ModulePath, "/", context.ModuleName, "/", viewName);
@prabirshrestha
prabirshrestha / 1 - UserModuleTest.cs
Created October 7, 2012 21:33
nancy testing example
using CsQuery;
using Nancy;
using Nancy.Testing;
using Should;
using Xunit;
public class UserModuleTest
{
[Fact]
public void WhenUserNotFound()
@prabirshrestha
prabirshrestha / Client.cs
Created October 22, 2012 01:52
Batch Request in nancy
using System.Net.Http;
class Program
{
static void Main(string[] args)
{
var client = new HttpClient();
var batchRequest = new HttpRequestMessage(HttpMethod.Post, "http://localhost:3440/api/batch");
namespace FacebookApi
{
using System;
using System.Threading;
using System.Threading.Tasks;
public class FacebookApi
{
private Func<object, string> serializeJson;
private static Func<object, string> defaultJsonSerializer;
namespace SimpleBlog
{
using System;
using System.Collections.Generic;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
public class SimpleBlog
{
public static AppFunc App(ISimpleBlogService service)
{
@prabirshrestha
prabirshrestha / gist:3962534
Created October 27, 2012 01:02
shared folder security dialog
caspol -m -ag 1.3 -url "file://\\vmware-host\shared folders/projects/*" FullTrust