Skip to content

Instantly share code, notes, and snippets.

View darrencauthon's full-sized avatar

Darren Cauthon darrencauthon

View GitHub Profile
public class ObjectUnderTest
{
private readonly MappingEngine mappingEngine;
public ObjectUnderTest(string prefix)
{
var configuration = new Configuration(new TypeMapFactory(), MapperRegistry.AllMappers());
configuration.CreateMap<Person, PersonModel>()
.ForMember(x => x.Name, y => y.MapFrom(orig => prefix + orig.Name));
//First the usage
//Would be cool to use it for taking out parameters from a table, when I only use a few parameters and don't have a real class
[Given(@"the following Dealer exists")]
public void GivenTheFollowingDealerExists(DynamicItems people)
{
var person = people.First();
string Id = Convert.ToInt32(person.Id);
string Name = person.Name;
// do your stuff
@darrencauthon
darrencauthon / AutomoqTest.cs
Created October 19, 2011 17:25 — forked from giggio/AutomoqTest.cs
AutoMoq problem when calling twice in a very specific scenario
using AutoMoq;
using NUnit.Framework;
namespace TestProject1
{
[TestFixture]
public class UnitTest1
{
private AutoMoqer mocker;
private SomeController controller;
public class FindPotentiallyMatchingExamsForCompletionSignOffQuery : Query<IEnumerable<ExamResult>>
{
public override IEnumerable<ExamResult> Execute()
{
ExamResult er = null;
Component c = null;
VibrationPoint vp = null;
ExamMethod m = null;
var matchingCodeSectionIds = QueryOver.Of(() => er)
.Where(() => er.Surveillance.Id == Surveillance)
params = {}
params[:to] = "[email protected]"
params[:subject] = "xxx"
params[:from] = ""
@@params = params
# need to add gem smoke_monster for this
items = [:to, :team, :from_email].to_objects {
[:blue, :red, :white, :black, :orange, :green, :yellow, :pink, :test].map do |color|
@darrencauthon
darrencauthon / jquery.nodoubletapzoom.js
Created July 15, 2012 13:24 — forked from johan/jquery.nodoubletapzoom.js
A jQuery plugin to selectively disable the iOS double-tap-to-zoom action on specific page elements (and have that generate two click events instead).
// jQuery no-double-tap-zoom plugin
// Triple-licensed: Public Domain, MIT and WTFPL license - share and enjoy!
(function($) {
var IS_IOS = /iphone|ipad/i.test(navigator.userAgent);
$.fn.nodoubletapzoom = function() {
if (IS_IOS)
$(this).bind('touchstart', function preventZoom(e) {
var t2 = e.timeStamp
def current_club
club_id = current_member ? current_member.club_id : 1
@club ||= Club.find(club_id)
end
@darrencauthon
darrencauthon / gist:3709316
Created September 12, 2012 19:32 — forked from jmeirow/gist:3709299
Text parsing and mapping in Ruby
# the big picture... what data we're getting from where and its destination
@data_binding_hash = {
:@pSMSR_GRGR_ID=> [ :GRGR_ID, 'facets_field', DataType.STRING, DataSource.FACETS, '@pSMSR_GRGR_ID=""' , nil ],
:@pSMSR_SBSB_ID=> [ :SBSB_ID, 'facets_field', DataType.STRING, DataSource.FACETS, '@pSMSR_SBSB_ID=""' , nil ],
:@pSMSR_REL=> [ :patient_rel_code, 'rel_code', DataType.STRING, DataSource.LOOKUP, '@pSMSR_REL=""' , nil ],
:@pSMSR_SSN=> [ :MEME_SSN, 'facets_field', DataType.STRING, DataSource.FACETS, '@pSMSR_SSN=""' , nil ],
:@pSMSR_LNAME=> [ :SBSB_LAST_NAME, 'facets_field', DataType.STRING, DataSource.FACETS, '@pSMSR_LNAME=""' , nil ],
:@pSMSR_FNAME=> [ :SBSB_FIRST_NAME, 'facets_field',
@darrencauthon
darrencauthon / gist:3709530
Created September 12, 2012 20:09 — forked from jmeirow/gist:3709453
Ruby-style enums
class DataType
[:STRING, :DATE, :UNKNOWN, :NUMERIC].each do |type|
self.instance_eval "def self.#{type};:#{type};end"
end
end
@darrencauthon
darrencauthon / to_range.rb
Created November 26, 2012 14:06 — forked from jmeirow/to_range.rb
create array of ranges from array of individual values
class Array
def to_range
highs = self.select { |x| self.include?(x+1) == false }.sort_by { |x| x }
lows = self.select { |x| self.include?(x-1) == false }.sort_by { |x| x }
(0...lows.count).map { |i| lows[i]..highs[i] }
end
end