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 class when_withdrawing_money_from_empty_account | |
{ | |
Establish context = ()=> depositor = new Depositor(13); | |
Because of = ()=> depositor.Withdraw(50.0m); | |
It should_decrease_balance = ()=> depositor.Balance.ShouldBeGreaterThan(0.01m); | |
It should_have_account_open = ()=> depositor.AccountIsOpen.ShouldBeTrue(); | |
} |
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
namespace DuckTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var connectionString = ConfigurationManager.ConnectionStrings["DB"].ConnectionString; | |
var db = new DuckContext(connectionString); | |
db.In<Person>() |
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
db.In<Person>().Insert(()=> new Person{ Name = "John", Age = 5, Id = 5 }) | |
.IfNotExists(()=> new Person{Name = "John", Age = 5}); | |
//intentionally kept the id out. | |
//This'll mean that we can handle creates in a kind of idempotent manner. |
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
var personId = new Guid("9438D2F0-AD99-45C0-86D3-CAF9C3E77CAF"); | |
//fails...says @p0 not passed in | |
db.In<Person>() | |
.Where(x => x.PersonId == personId) | |
.Update(x => new Person { Name = "XX" }); | |
//succeeds | |
db.In<Person>() | |
.Where(x => x.PersonId == new Guid("9438D2F0-AD99-45C0-86D3-CAF9C3E77CAF")) |
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 abstract class DenormalizerTest<TDenormalizer, TView> | |
{ | |
public abstract IEnumerable<Event> GivenTheseEvents(); | |
public abstract IQueryable<TView> WhenIPerformThisQuery(); | |
public abstract IEnumerable<TView> IShouldGetTheseResults(); | |
[Test] | |
public void PerformTest() | |
{ | |
var events = GivenTheseEvents(); |
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
<select data-bind='value:selected, options:availableOptions, optionsText:'name' /> | |
<div data-bind='template:{"name":resolveTemplate, data:selected}' /> | |
var vm = { | |
'selected' : ko.observable(''), | |
'availableOptions' : ko.ObservableArray([{'name':'foo', 'value':'fooval}, {'name':'bar', 'value':'barval'}]), | |
'resolveTemplate' : function(){ | |
var selectedItem; | |
selectedItem = selected(); | |
if(selectedItem){ |
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
namespace System | |
{ | |
public static class ObjectExtensions | |
{ | |
public static bool ContainsKey(this object target, string key) | |
{ | |
return target.GetType().GetProperties().Any(x => x.Name == key); | |
} | |
} | |
} |
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 IDictionary<string, object> ToDictionary(this object target) | |
{ | |
return target.GetType().GetProperties().ToDictionary(x => x.Name, y => y.GetValue(target, new object[] { })); | |
} |
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
if(!window.MYNAMESPACE) window.MYNAMESPACE = {}; | |
window.MYNAMESPACE.proxy = function(){ | |
var that, someSharedVariable; | |
that = {}; | |
someSharedVariable = 10; | |
that.doSomething = function(){ | |
callJqueryOrSomething(); | |
//use someSharedVariable; |
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
var date = getDate(); | |
var format = 'dd-MM-yyyy hh:mm:ss'; | |
var formattedDate = $.format.date(date, format); | |
alert(formattedDate); //alerts 02-01-2012 12:23:41 |
OlderNewer