Skip to content

Instantly share code, notes, and snippets.

@onefloridacoder
Created May 2, 2011 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onefloridacoder/952542 to your computer and use it in GitHub Desktop.
Save onefloridacoder/952542 to your computer and use it in GitHub Desktop.
Sample code to demo StoryQ fluid syntax.
namespace BarCamp
{
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using StoryQ;
using System;
using System.Collections;
[TestClass]
public class RegistrationStory
{
[TestInitialize]
public void InitTestReporter()
{
StoryQSettings.ReportSupportsLegacyBrowsers = true;
}
[TestMethod]
public void CreateAttendeeProfile()
{
IDictionary profile = new Dictionary<string, string>();
// StoryQSettings.ReportSupportsLegacyBrowsers = true;
new Story("CreateAttendee").Tag("Sprint1")
.InOrderTo("Create a new Attendee Profile")
.AsA("code camp attendee")
.IWant("to be able to save my profile information")
.WithScenario("Create New Attendee Profile")
.Given(IHaveAValidEmailAddress, "bill@microsoft.com")
.And(MyProfileDoesNotExistAlready, "bill@microsoft.com")
.When(ISaveMyProfileInformation, profile)
.Then(ICanRetrieveMyProfile, "bill@microsoft.com")
.ExecuteWithReport();
}
[TestMethod]
public void UpdateAttendeeEmail()
{
// StoryQSettings.ReportSupportsLegacyBrowsers = true;
new Story("UpdateAttendeeProfile").Tag("Sprint2")
.InOrderTo("Update an Attendee Email")
.AsA("code camp attendee")
.IWant("to be able to change my email address")
.WithScenario("Update Attendee Profile")
.Given(IHaveAValidEmailAddress, "bill@microsoft.com")
.When(IEnterMyNewEmailAddress, "bill@microsoft.com")
.Then(MyExistingEmailAddressIsUpdated, "bill@microsoft.com", "steve@microsoft.com")
.ExecuteWithReport();
}
public void IHaveAValidEmailAddress(string newEmailAddress)
{
Assert.IsTrue(!(String.IsNullOrEmpty(newEmailAddress)));
}
public void IEnterMyNewEmailAddress(string newEmailAddress)
{
// Code to replace old address with new address
Assert.IsTrue(newEmailAddress == "bill@microsoft.com");
}
public void MyExistingEmailAddressIsUpdated(string oldEmailAddress, string newEmailAddress)
{
// Code to compare old email address with persisted email address
Assert.IsTrue(!(oldEmailAddress.Equals(newEmailAddress)));
}
public void MyProfileDoesNotExistAlready(string profileKey)
{
// Code to search for existing profile
}
public void ISaveMyProfileInformation(IDictionary profile)
{
IProfileManager mgr = new ProfileManager();
mgr.Save(profile);
}
public void ICanRetrieveMyProfile(string emailAddress)
{
IProfileManager mgr = new ProfileManager();
var profile = mgr.FindAttendeeProfile(emailAddress);
}
}
}
@onefloridacoder
Copy link
Author

This represents the StoryQ syntax for a code camp scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment