Skip to content

Instantly share code, notes, and snippets.

@alexyork
alexyork / ASP.NET MVC Blog Tests
Created October 25, 2010 18:44
ASP.NET MVC Blog Tests
using System;
using NUnit.Framework;
namespace MvcBlogEngine.Tests.Controllers
{
public partial class WidgetControllerSpec
{
[TestFixture]
public partial class TagCloud : BDDTest
{
@alexyork
alexyork / Ugly!
Created September 21, 2010 11:34
Ugly.cs
// Unformatted / unindented
new Nullable<decimal>().GetValueOrDefault().GetType().GetMethod("Parse", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string) }, null).Invoke(null, new object[] { "123,45" })
// Formatted / indented
new Nullable<decimal>().GetValueOrDefault()
.GetType()
.GetMethod("Parse",
BindingFlags.Static | BindingFlags.Public,
null,
new Type[] { typeof(string) },
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace RefactoringNeeded
{
#region Alert filter
public static class AlertFilter
{
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace RefactoringNeeded
{
#region Alert filter
public static class AlertFilter
{
// Jasmine
// http://pivotal.github.com/jasmine/
describe("Calculator", function() {
it("should add two numbers correctly", function() {
var result = add(3, 4);
expect(result).toEqual(7);
});
// Example 1
var query = from item _dataContext.PublishedItems
select item;
// When enumerated (i.e. looped) over, "query" will go to the DB, and get all items
// Calling a WCF Data Service with jQuery
//
// This will generate a URL like this...
// http://example.com/Products.svc/Customers(1234)/Orders?$skip=10&top=10
// ... and pass the JSON data result to your callback function
$.fromServiceUrl("http://example.com/Products.svc")
.queryTable("Customers", 1234)
.withRelation("Orders")
.skip(10)