Skip to content

Instantly share code, notes, and snippets.

@hatelove
hatelove / gist:95df086d04937664765d
Created July 7, 2014 05:23
把 table schema dump 出來的 SQL
DECLARE @tableName nvarchar(30)
SET @tableName ='你的table名字'
SELECT
IC.TABLE_NAME AS [IC_TableName],
td.value AS [Table Description],
c.name AS [Column Name],
IC.DATA_TYPE,
IC.CHARACTER_MAXIMUM_LENGTH,
SM.TEXT AS "Column Default Value",
[Binding]
[Scope(Feature = "StockChanging")]
public class StockChangingSteps
{
private JoeyTestEntities dbContext;
private StockChangesService target;
[BeforeScenario]
public void BeforeScenario()
{
@hatelove
hatelove / gist:b9925b9f7cd230b6ed90
Created June 5, 2014 09:26
Tuple與匿名型別偷吃步的比較方式,只比較特定值
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
namespace CollectionAssertSample
{
[TestClass]
public class UnitTest1
{
public enum Command
{
Next,
Reset
}
public enum State
{
State1,
State2,
@hatelove
hatelove / Login.feature
Last active August 29, 2015 14:01
Login Feature & Steps
Feature: Login
In order to 避免非法使用者使用系統
As a 系統管理者
I want to be 檢查帳號密碼是否合法
Scenario: 登入成功,導到首頁
Given Login的頁面
When 在帳號輸入"joey"
And 在密碼輸入"1234"
And 按下登入
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--Default Root Path-->
<PropertyGroup>
<SolutionPath>$(MSBuildStartupDirectory)\MySolution.sln</SolutionPath>
<UnitTestSettingPath>$(MSBuildStartupDirectory)\MyTestSetting.testsettings</UnitTestSettingPath>
<AnalysisFileIncludes>$(MSBuildStartupDirectory)\**\*.cs</AnalysisFileIncludes>
<AnalysisFileExcludes>$(MSBuildStartupDirectory)\*Test*\**\*.*</AnalysisFileExcludes>
<ScenarioSourcePath>$(MSBuildStartupDirectory)\MyScenarioFolder</ScenarioSourcePath>
</PropertyGroup>
Process 就像是「套路」。
沒有內功,只有套路,那只是花拳繡腿。
就像下面這一段:亢龍有悔。
「洪七公左腿微屈,右臂內彎,右掌劃了個圓圈,呼的一聲,向外推去,手掌掃到面前一棵松樹,喀喇一響,松樹應手斷折。 」
「郭靖拉開式子,挑了一棵特別細小的松樹,學著洪七公的姿勢,對準樹幹,呼的就是一掌。那松樹晃了幾晃,竟是不斷。洪七公罵道:『傻小子,你搖松樹幹什麼?捉松鼠麼?撿松果麼?』」
在業界往往軟體工程導入,通常都是看到人家只是「左腿微屈,右臂內彎,右掌劃了個圓圈,呼的一聲,向外推去,手掌掃到面前一棵松樹,喀喇一響,松樹應手斷折」。然後就超級心動,覺得這招亢龍有悔真是好物!肯定可以讓我們輕鬆破敵!
@hatelove
hatelove / gist:7409682
Created November 11, 2013 08:22
需要用 mock 測試的 sample
using System;
using System.Collections.Generic;
namespace MessageHandler.Test
{
public class MyService
{
private ICustomerDao _customerDao;
public MyService(ICustomerDao customerDao)
Feature: Score Calculation
As a player
I want the system to calculate my total score
So that I know my performance
Scenario: Homework scenario 1
Given a new bowling game
When I roll the following series: 10,1,5,2,8,4,6,10,3,2,1,2,1,0,1,1,2,8,6
Then my total score should be 98
@hatelove
hatelove / MyExtensionMethod.cs
Created August 1, 2013 03:41
Implementation of OrderBy and ThenBy
// implement OrderBy and ThenBy
// reference1: http://msmvps.com/blogs/jon_skeet/archive/2011/01/04/reimplementing-linq-to-objects-part-26a-iorderedenumerable.aspx
// reference2: http://msmvps.com/blogs/jon_skeet/archive/2011/01/05/reimplementing-linq-to-objects-part-26b-orderby-descending-thenby-descending.aspx
using System;
using System.Collections.Generic;
using System.Linq;
namespace OrderByAndThenBySample
{