Skip to content

Instantly share code, notes, and snippets.

@lefthandedgoat
Created September 19, 2013 20:39
Show Gist options
  • Save lefthandedgoat/6629498 to your computer and use it in GitHub Desktop.
Save lefthandedgoat/6629498 to your computer and use it in GitHub Desktop.
let skipTo stepName client =
let wizardSteps = [
(20, 1, "Company Info");
(48, 1, "Login");
(49, 1, "Password Rules");
... lots more
(66, 13, "Publish Rules");]
if not (wizardSteps |> List.exists(fun (id, groupid, name) -> name = stepName)) then failwith (sprintf "Step %s does not exist" stepName)
canopyExtensions.skipUntil <- stepName
//hack, at this point we have registered X test to run, then register this nameless test, then stop accepting tests with the line above and canopyextension.&&&
runner.test (fun _ ->
let clientName, _, _, _ = getClient client
let clientId = repository.Queryable<Client>().FirstOrDefault(fun (x:Client) -> x.Name = clientName).Id
let currentContext = runner.suites |> List.filter( fun s -> s.Context = "Adding clients") |> List.head
currentContext.Tests <- []
let index = wizardSteps |> List.findIndex (fun (id, groupid, name) -> name = stepName)
wizardSteps
|> Seq.take index
|> Seq.iter(fun (id, groupid, name) ->
let configurationItem = repository.Queryable<AdminWizardConfigurationItem>().FirstOrDefault(fun (x:AdminWizardConfigurationItem) -> x.Id = System.Convert.ToInt64(id))
let awp = new AdminWizardProgress()
awp.ClientId <- clientId
awp.ConfigurationItem <- configurationItem
awp.IsComplete <- true
repository.Save(awp)
)
)
==================
let mutable private testAdded = false
let mutable skipUntil : string = null
let ( &&& ) (description : string) f =
if description.StartsWith(skipUntil + ":") then testAdded <- true
if skipUntil = null || testAdded || description = "Run the configuration wizard for the new client" then //yah yah its hacky
(last suites).Tests <- (last suites).Tests @ [Test(description, f, (last suites).Tests.Length + 1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment