This file contains 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
void WaitForMicroOutageToPass() //call this from your constructor | |
{ | |
if (!Database.Exists()) | |
{ | |
return; | |
} | |
var connection = Database.Connection; | |
for (int i = 0; i < 10; i++) | |
{ |
This file contains 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 TValue GetValueOrDefault<TKey, TValue> (this Dictionary<TKey, TValue> d, TKey key, TValue defaultValue = default(TValue)) | |
{ | |
TValue value; | |
return d.TryGetValue(key, out value) ? value : defaultValue; | |
} |
This file contains 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
[Trait("Category", "Spike")] | |
public class OomBuilder | |
{ | |
const string StaticConverter = @" | |
public static {{To}} To{{To}}({{From}} src) | |
{ | |
return new {{To}} | |
{ | |
{{#each Matches}} | |
{{this}} = src.{{this}},{{/each}} |
This file contains 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
ALTER PROC sp_generate_inserts | |
( | |
@table_name varchar(776), -- The table/view for which the INSERT statements will be generated using the existing data | |
@target_table varchar(776) = NULL, -- Use this parameter to specify a different table name into which the data will be inserted | |
@include_column_list bit = 1, -- Use this parameter to include/ommit column list in the generated INSERT statement | |
@from varchar(800) = NULL, -- Use this parameter to filter the rows based on a filter condition (using WHERE) | |
@include_timestamp bit = 0, -- Specify 1 for this parameter, if you want to include the TIMESTAMP/ROWVERSION column's data in the INSERT statement | |
@debug_mode bit = 0, -- If @debug_mode is set to 1, the SQL statements constructed by this procedure will be printed for later examination | |
@owner varchar(64) = NULL, -- Use this parameter if you are not the owner of the table |
This file contains 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
/// <summary> | |
/// Speclight users like to see "Pending" steps (that throw NotImplementedException) as "skip" not "fail" | |
/// </summary> | |
public class SpecAttribute : FactAttribute | |
{ | |
protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method) | |
{ | |
yield return new SkipIfNotImplemented(method); | |
} |
This file contains 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 ApprovalNameEnhancer : SpecFixtureBase | |
{ | |
public override void StepSetup(Step step) | |
{ | |
//tack the step description onto the approval file name: | |
NamerFactory.AdditionalInformation = step.Description; | |
//ok, but what if the step used twice in the same spec (with the same arguments)? | |
var dupes = step.Spec.Steps.Where(x => x.Description == step.Description); | |
var index = dupes.ToList().IndexOf(step); |
This file contains 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
// Complementary to http://gist.github.com/406014. Just swap your BDD<T> base class for DBDD | |
// Also licensed under MSPL/FreeBSD/ISC | |
public abstract class DBDD | |
{ | |
public readonly dynamic Given; | |
public readonly dynamic When; | |
public readonly dynamic Then; | |
public readonly dynamic And; |
This file contains 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.IO; | |
using System.Linq; | |
namespace Regionator | |
{ | |
public class Program | |
{ | |
const int TargetSpacesPerIndent = 3; |
This file contains 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 CodeTimer : IDisposable | |
{ | |
private readonly string _message; | |
private readonly Stopwatch _sw = new Stopwatch(); | |
public CodeTimer(string message) | |
{ | |
_message = message; | |
_sw.Start(); | |
} |
This file contains 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 FillingLine : Path | |
{ | |
Size lastFinalSize; | |
protected override Size MeasureOverride(Size availableSize) | |
{ | |
return new Size(0, 0); | |
} | |
protected override Size ArrangeOverride(Size finalSize) |
OlderNewer