Skip to content

Instantly share code, notes, and snippets.

View JuanjoFuchs's full-sized avatar

Juan José Fuchs JuanjoFuchs

View GitHub Profile
@JuanjoFuchs
JuanjoFuchs / LSP_Animal.Refactorizado.cs
Created June 8, 2012 15:15
Ejemplo del principio de sustitución de Liskov (LSP)
namespace LSP_Animal.Refactorizado
{
public abstract class Animal
{
public abstract void Alimentar();
}
public interface IMascota
{
void Acariciar();
@JuanjoFuchs
JuanjoFuchs / DIP_HolaMundo.Refactorizado.cs
Created June 8, 2012 15:21
Ejemplo del principio de Inversión de Dependencias (DIP)
using System;
namespace DIP_HolaMundo.Refactorizado
{
public class HolaMundo
{
private DateTime _horaDelSaludo;
public HolaMundo(DateTime horaDelSaludo)
{
@JuanjoFuchs
JuanjoFuchs / OCP_Empleados.Refactorizado.cs
Created June 8, 2012 15:41
Ejemplo del principio Abierto Cerrado (OCP)
using System.Collections.Generic;
namespace OCP_Empleados.Refactorizado
{
public abstract class Empleado
{
public string Nombre { get; set; }
public double Sueldo { get; set; }
public double Bono { get; set; }
@JuanjoFuchs
JuanjoFuchs / WebExtensions.ToJson.cs
Created December 17, 2012 15:35
Very small extension to easily convert a Json ActionResult into the object it represents.
using System.Web.Mvc;
public static class WebExtensions
{
public static T ToJson<T>(this ActionResult actionResult)
{
var jsonResult = (JsonResult)actionResult;
return (T)jsonResult.Data;
}
@JuanjoFuchs
JuanjoFuchs / Resharper.CodeTemplates.NUnit.NewTest.DotSettings
Created December 17, 2012 16:04
Resharper code template to rapidly create new tests. Just import the .DotSettings file into resharper templates explorer or pase the code in .cs into a new template.
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1CCA467D3460634792E903194CBBECED/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1CCA467D3460634792E903194CBBECED/Shortcut/@EntryValue">test</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1CCA467D3460634792E903194CBBECED/Description/@EntryValue">Create a new NUnit test</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1CCA467D3460634792E903194CBBECED/Text/@EntryValue">[Test]&#xD;
public void $Test$()&#xD;
{&#xD;
$SELSTART$Assert.Fail("Not yet implemented");$SELEND$&#xD;
}</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTe
@JuanjoFuchs
JuanjoFuchs / Resharper.CodeTemplates.NUnit.Setup.DotSettings
Created February 1, 2013 20:31
Resharper code template to create setup method. Just import the .DotSettings file into resharper templates explorer or paste the code in .cs into a new template.
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6F969D82676C6E4EAB872A29F8652DA0/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6F969D82676C6E4EAB872A29F8652DA0/Shortcut/@EntryValue">setup</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6F969D82676C6E4EAB872A29F8652DA0/Description/@EntryValue">Creates a SetUp method</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6F969D82676C6E4EAB872A29F8652DA0/Text/@EntryValue">[SetUp]&#xD;
public void SetUp()&#xD;
{&#xD;
$END$&#xD;
}</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6F969D82676C6E4EAB872A29F8652D