Skip to content

Instantly share code, notes, and snippets.

View jwChung's full-sized avatar

Jin-Wook Chung jwChung

View GitHub Profile
@jwChung
jwChung / gist:5626059
Last active December 17, 2015 14:39
EF question
public class QueryingFindingEntities
{
[Fact]
public void FindingEntityByPrimaryKey()
{
using (var context = new BlogContext())
{
int execuedCount = 0;
context.RegisterCallbackStateChanged(ConnectionState.Open, () => execuedCount++);
@jwChung
jwChung / gist:5812597
Created June 19, 2013 08:22
SerializableMultidimensionalArray
public class SerializableMultidimensionalArray : IXmlSerializable
{
private readonly int[,] array = new int[3, 2];
public int this[int i, int j]
{
get
{
return this.array[i, j];
}
@jwChung
jwChung / exception1
Last active December 25, 2015 11:49
exception from slipp
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
@jwChung
jwChung / CollectingPropertiesTest.cs
Last active August 29, 2015 14:04
ExpressionVisitor demo
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using Xunit;
namespace ClassLibrary1
{
public class CollectingPropertiesTest
{
@jwChung
jwChung / MockExtensions.cs
Created September 1, 2014 03:42
The Of extension method to confiture existing a mocked instance using LINQ query syntax.
namespace Jwc.MoqExtensions
{
using Moq;
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Xunit;
public interface IFoo
@jwChung
jwChung / Mocked.cs
Created September 7, 2014 15:16
Mocked.cs
namespace Jwc.Experiment.Xunit
{
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Moq;
public static class Mocked
{
@jwChung
jwChung / FakeDbSet.cs
Last active August 29, 2015 14:09
FakeDbSet
namespace ArticleHarbor.DomainModel
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Linq.Expressions;
public interface IPageViewTracker
{
IDisposable Track(Page page);
}
public class NamedPageViewTracker : IPageViewTracker
{
public NamedPageViewTracker(
IPageViewTracker innerTacker, IPageViewNameProvider provider)
{
public interface IFactory<T>
{
T Create();
}
public class CacheFactory<T> : IFactory<T>
{
private T cached;
private readonly object syncLook = new object();
@jwChung
jwChung / factory-patterns.cs
Last active April 3, 2016 12:35
Factory Method vs Abstract Factory
using System;
namespace ClassLibrary3
{
public interface IProduct
{
}
public class Foo : IProduct
{