Skip to content

Instantly share code, notes, and snippets.

[Binding]
[Scope(Feature = "StockChanging")]
public class StockChangingSteps
{
private JoeyTestEntities dbContext;
private StockChangesService target;
[BeforeScenario]
public void BeforeScenario()
{
@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",
@hatelove
hatelove / step.cs
Created September 10, 2014 16:16
103 web testing demo sample - FluentAutomation
Feature: 登入
Scenario: 登入成功
Given 我連到登入頁面
And 我在帳號輸入 "joey"
And 我在密碼輸入 "1234"
When 我按下登入按鈕
Then 應該被導到首頁
Scenario: 登入失敗
this.Then(/^item info - "([^"]+)" should match/, function(key, next) {
itemPage.getInfo(key).then(
function(data) {
//data: {info, pattern}
expect(data.pattern.test(data.info), 'itemInfo match error').to.be.true;
}
).then(next, next);
});
@hatelove
hatelove / mockNow.cs
Created November 18, 2014 02:23
mock DateTime example
[TestMethod]
public void TestMethod1()
{
//arrange
var p = new Person();
MockContext.MockNow = new DateTime(2011, 1, 1);
var result = p.Cal();
public interface IFoo
{
string Bar(int a, string b);
}
[TestMethod]
public void Test_ReturnFromFunction_CallInfo()
{
var foo = Substitute.For<IFoo>();
foo.Bar(0, "").ReturnsForAnyArgs(x => "Hello " + x.Arg<string>());
@hatelove
hatelove / gist:3122ef16b4ab999af016
Created December 11, 2014 11:06
from Rhino.Mocks to NSub
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
//using Rhino.Mocks;
using RsaSecureToken;
using NSubstitute;
順便補充一下,昨天問到我那個 「Google Search 的 feature,幾乎就把整個 product 涵蓋完」了的問題。
今天早上走到公司的時候,有一些比較清晰的想法。
其實重點還是回歸到 user story。我們現在看到最後的 user story 都是精鍊過的,所以可能比較沒有感覺。
一樣是 search engine,我舉幾個例子來描述不同的 user story。
user story 1:
我是一個阿宅,平時很少出門逛街買東西,更不知道女生喜歡什麼樣的東西。有一次,我喜歡的女生在 Facebook 上貼了一篇文章,提到網頁上那個女生的包包一整個是她的菜。
我喜歡她,她的生日快到了,我想要在她生日的時候,送她這個包包。但我壓根不知道包包該去哪買,包包的相關資訊。
所以我希望,我可以在搜尋首頁上,貼上那個包包的圖片,就可以找到這個包包的相關資訊。讓我可以有機會,追到這個女生。
Feature: 以圖找圖
@hatelove
hatelove / xUnitSample.cs
Created May 16, 2015 15:43
xUnit 驗證 exception 內容的方式
public class UnitTest1
{
[Fact]
public void TestMethod1()
{
var target = new Joey();
var ex = Assert.Throws(typeof(ArgumentException), () => { target.ThrowEx(2); });
Assert.True(ex.Message.Contains("不能是偶數"));
@hatelove
hatelove / MVP2016.cs
Last active October 20, 2015 09:57 — forked from demofan/MVP2016.cs
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NSubstitute;
namespace MvpRenewTest
{
[TestClass]
public class MvpTests
{
//[TestMethod]
//public void TestMethod_MVP現有類別不在指定類別內並且不是十月份MVP可以自動延長一年()