This file contains hidden or 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 static Func<TReturn> Memoize<TReturn>(Func<TReturn> func) | |
| { | |
| object cache = null; | |
| return () => | |
| { | |
| if (cache == null) | |
| cache = func(); | |
| return (TReturn)cache; | |
| }; | |
| } |
This file contains hidden or 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.Collections.Generic; | |
| using NUnit.Framework; | |
| namespace GoodParts | |
| { | |
| [TestFixture] | |
| public class GenericsTest | |
| { | |
| [Test] |
This file contains hidden or 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.Collections.Generic; | |
| using System.Linq; | |
| using NUnit.Framework; | |
| namespace GoodParts | |
| { | |
| class Lambdas | |
| { |
This file contains hidden or 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; | |
| public static class EnumerableUtils { | |
| // First item, or throw 404 exception | |
| public static TSource FirstOr404<TSource>(this IEnumerable<TSource> source) | |
| { | |
| try | |
| { | |
| return source.First(); |
This file contains hidden or 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
| class window.TodoView extends Backbone.View | |
| tagName: "li" | |
| template: _.template($('#item-template').html()) | |
| events: | |
| "click .check" : "toggleDone" | |
| "dblclick div.todo-content" : "edit" | |
| "click span.todo-destroy" : "clear" | |
| "keypress .todo-input" : "updateOnEnter" |
This file contains hidden or 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
| window.TodoView = Backbone.View.extend | |
| tagName: "li" | |
| template: _.template($('#item-template').html()) | |
| events: | |
| "click .check" : "toggleDone", | |
| "dblclick div.todo-content" : "edit", | |
| "click span.todo-destroy" : "clear", | |
| "keypress .todo-input" : "updateOnEnter" |
This file contains hidden or 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
| initialize: -> | |
| @model.bind('change', this.render) | |
| @model.view = this | |
| render: => | |
| $(@el).html(this.template(@model.toJSON())) | |
| this.setContent() | |
| return this |
This file contains hidden or 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
| initialize: -> | |
| this.model.bind('change', this.render) | |
| this.model.view = this | |
| render: => | |
| $(this.el).html(this.template(this.model.toJSON())) | |
| this.setContent() | |
| return this |
This file contains hidden or 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
| initialize: -> | |
| _.bindAll(this, 'render', 'close') | |
| this.model.bind('change', this.render) | |
| this.model.view = this | |
| render: -> | |
| $(this.el).html(this.template(this.model.toJSON())) | |
| this.setContent() | |
| return this |
This file contains hidden or 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
| [When("I choose a photo to upload")] | |
| public void UploadImageFor() | |
| { | |
| // Where Browser is your current Browser object | |
| var fileUpload = Browser.FileUpload(x => x.Name == "Photo"); | |
| var assembly = Assembly.GetExecutingAssembly(); | |
| var fileStream = assembly.GetManifestResourceStream(assembly.GetName().Name + ".TestData.image.jpg"); | |
| var fileData = new byte[fileStream.Length]; | |
| fileStream.Read(fileData, 0, fileData.Length); |