Skip to content

Instantly share code, notes, and snippets.

@ToJans
Created May 23, 2012 15:08
Show Gist options
  • Select an option

  • Save ToJans/2775794 to your computer and use it in GitHub Desktop.

Select an option

Save ToJans/2775794 to your computer and use it in GitHub Desktop.
How we perform integration testing at Paycento
This is how we currently run integration tests for Paycento
===========================================================
More info: ToJans@twitter
This is what happens when we type "Heracles test" on the command line.
- It downloads the source from svn if it is not available yet
- It copies some external dependencies from a subfolder to the source
- It build the solutions & copies the builds in a build folder
- It deploys web projects to a local folder
- It runs the integration tests in IntegrationTests.dll
IntegrationTests.DLL contains some basic integration testing for the API:
-------------------------------------------------------------------------
Environment setup is extremely simple using helper classes in this project
using (new PaycentoAPIContext())
=> Starts a completely new Paycento.API WCF service in-process accessible over http;
this API instance uses a new database instance which is restored from a backup (via a file or over http).
Cleanup happens upon Dispose.
using (new IISHelper(webrooturl,port=80))
=> Fires up a website using ISSExpress.
Example Spec:
-------------
Below You can find an example spec implementation (the behavior is bound to change).
Prerequisites required to handle everything mentioned here:
- Heracles.zip
- Asp.Net MVC4
- MSBuild
- SQL Server 2008 (express) or better
- Azure SDK
- Internet connection
using System.Configuration;
using System.Linq;
using IntegrationTests.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
namespace IntegrationTests
{
[TestClass]
public class MerchantBehavior
{
public string ConsumerKey { get { return ConfigurationManager.AppSettings["PaycentoMerchantKey"]; } }
[TestMethod]
public void RequestSomeMerchantData()
{
using (new PaycentoAPIContext())
{
var conn = new Paycento.MerchantConnector.PaycentoConnect("localhost",true,"application/json");
string err = null;
var sessiontoken = Paycento.APIConnector.Helper.CreateSessionKey();
sessiontoken.ShouldNotBe(null);
string name = conn.GetMerchantName(ConsumerKey, ref err);
err.ShouldBe(null);
name.ShouldBe("John Titor");
var walletsresponse = conn.LoadMerchantWallets(ConsumerKey, sessiontoken, ref err);
err.ShouldBe(null);
walletsresponse.TotalCount.ShouldBe(5);
var defaultwallet = walletsresponse.Wallets.First(x => x.DefaultWallet == true);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment