Skip to content

Instantly share code, notes, and snippets.

View jcteague's full-sized avatar

John Teague jcteague

  • CapitalOne
  • Austin, TX
View GitHub Profile
public static class TestViewExtension
{
public static string RenderViewUnderTest(this HtmlHelper helper, string controller, string action, object model)
{
var ctx = new ViewDataDictionary(model);
helper.ViewContext.RouteData.Values["Controller"] = controller;
helper.ViewContext.RouteData.Values["Action"] = action;
var sw = new StringWriter();
var viewContext = new ViewContext(helper.ViewContext, helper.ViewContext.View,ctx,helper.ViewContext.TempData, sw);
require 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
class ConfigurationSettingsHackery
def set_config_file(new_config_file)
set_config_file_on_current_app_domain(new_config_file)
refresh_current_client_config_paths
reset_configuration_manager_to_force_reload
end
@jcteague
jcteague / IOC container test
Created December 2, 2010 23:57
IOC and Mocking Class that has a dependency on another concreate object
public class when_using_an_class_without_an_interface
{
private static SansInterfaceConsumer consumer;
private Establish context = () =>
{
ObjectFactory.Initialize(x =>
{
x.ForConcreteType<SanInterfaceService>();
x.ForConcreteType<SansInterfaceConsumer>();
@jcteague
jcteague / DialogElement.cs
Created May 16, 2011 01:55
UI Testing JQuery Dialog With Selenium
public class DialogElement
{
readonly IWebDriver _driver;
readonly string _idSelector;
public DialogElement(IWebDriver driver, string idSelector)
{
_driver = driver;
_idSelector = idSelector;
}
@jcteague
jcteague / BasicFilter.cs
Created June 4, 2011 05:19
Convention Approach to Creating Filters with Nhibernate
public class BasicFilter
{
public Guid? ClientGroupId { get; set; }
[LikeQueryFilter(ComponentModel = typeof (Address))]
public string AddressCity { get; set; }
[QueryFilter(ComponentModel = typeof (Address))]
public string AddressState { get; set; }
@jcteague
jcteague / expressionbuiler.cs
Created July 20, 2011 03:19
Trying to Run a test with ExpressionBuilder classes
// how I'm creating the processor factory
var processorFactory = ProcessorFactory.GetFactory(options.DatabaseType);
var processor = processorFactory.Create(_configuration.ConnectionString,announcer, new ProcessorOptions
{
PreviewOnly = false,
Timeout = options.Timeout
});
//executing the migrations
migration.ExecuteWith(migration_processor);
@jcteague
jcteague / FileRepository.cs
Created October 26, 2011 21:57
File Repository I was about to delete. Wanted to keep it somewhere
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
using System.Xml.Serialization;
namespace MvcTraining.Services
{
public interface IRepository<T>
{
@jcteague
jcteague / 1.js
Created May 7, 2012 21:17 — forked from mxriverlynn/1.js
ajax command wrapper
var signForm = $.ajax({
type: "POST",
url: "/some/form",
dataType: "JSON",
data: myData
});
signForm.done(function(response){
// handle success here
});
@jcteague
jcteague / gist:3800448
Created September 28, 2012 15:14
rendering collection+json media type
var root_url = "/api"
, templates = {}
, collection_templates = {}
, link_template
, resource_template
, resource_item_template
, resource_link_template
, form_field_template;
var get = function (url, callback) {
@jcteague
jcteague / links_or_actions.js
Created October 16, 2012 20:51
links or actions