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
<# | |
.SYNOPSIS | |
Quick deploy to various environments. | |
.DESCRIPTION | |
Calls deploy.ps1 with relevant arguments for repeatable deployments. | |
.PARAMETER deployTo | |
Specify the environment to deploy to. Currently supports "Dev-CMS" and "Dev-CD" |
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 ApiIntegrationFixture : IDisposable | |
{ | |
public ApiIntegrationFixture() | |
{ | |
var config = new HttpConfiguration(); | |
WebApiConfig.Register(config); | |
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; | |
//remember to add all filters | |
config.Filters.Add(new ValidationActionFilter()); |
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 AutoMoqControllerDataAttribute : AutoDataAttribute | |
{ | |
public AutoMoqControllerDataAttribute() | |
: base(new Fixture() | |
.Customize(new AutoMoqControllerCustomization())) | |
{ | |
} | |
} | |
public class AutoMoqControllerCustomization : CompositeCustomization |
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
[AttributeUsage(AttributeTargets.Class,AllowMultiple = false, Inherited = false)] | |
public class CacheAttribute : Attribute | |
{ | |
/// <summary> | |
/// The name of the cache profile to be used | |
/// </summary> | |
public string ProfileName { get; set; } | |
/// <summary> | |
/// Lifespan of the response in the cache |
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 class MethodInfoExtensions | |
{ | |
/// <summary> | |
/// Will return the name of the action specified in the ActionNameAttribute for a method if it has an ActionNameAttribute. | |
/// Will return the name of the method otherwise. | |
/// </summary> | |
/// <param name="method"></param> | |
/// <returns></returns> | |
public static string ActionName(this MethodInfo 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 static class AttributeExtensions | |
{ | |
/// <summary> | |
/// Will return true if the attributeTarget is decorated with an attribute of type TAttribute. | |
/// Will return false if not. | |
/// </summary> | |
/// <typeparam name="TAttribute"></typeparam> | |
/// <param name="attributeTarget"></param> | |
/// <returns></returns> | |
public static bool IsDecoratedWith<TAttribute>(this ICustomAttributeProvider attributeTarget) where TAttribute : Attribute |
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 HttpContextBuilder | |
{ | |
private Mock<HttpContextBase> _context; | |
private Mock<HttpRequestBase> _request; | |
private Mock<HttpResponseBase> _response; | |
private Mock<HttpSessionStateBase> _session; | |
private Mock<HttpServerUtilityBase> _server; | |
private Mock<IPrincipal> _user; | |
private Mock<IIdentity> _identity; |
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> | |
/// Used to simplify testing routes and restful testing routes | |
/// <example> | |
/// This tests that incoming PUT on resource is handled by the update method of the Banner controller | |
/// "~/banner/1" | |
/// .WithMethod(HttpVerbs.Put) | |
/// .ShouldMapTo<BannerController>(action => action.Update(1)); | |
/// </example> | |
/// </summary> | |
public static class RouteTestingExtensions |
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 ValidateObjectAttribute: ValidationAttribute { | |
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { | |
var results = new List<ValidationResult>(); | |
var context = new ValidationContext(value, null, null); | |
Validator.TryValidateObject(value, context, results, true); | |
if (results.Count != 0) { | |
var compositeResults = new CompositeValidationResult(String.Format("Validation for {0} failed!", validationContext.DisplayName)); | |
results.ForEach(compositeResults.AddResult); |
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> | |
/// Postcode validation attribute | |
/// Must be uppercase with a single optional space | |
/// </summary> | |
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] | |
public class PostcodeAttribute : DataTypeAttribute | |
{ | |
private static readonly Regex _regex = new Regex(@"^(GIR ?0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]([0-9ABEHMNPRV-Y])?)|[0-9][A-HJKPS-UW]) ?[0-9][ABD-HJLNP-UW-Z]{2})$"); | |
//if you need lowercase and multi space use this one |