Created
September 21, 2012 16:32
-
-
Save lefthandedgoat/3762507 to your computer and use it in GitHub Desktop.
multi-lib tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Learn more about F# at http://fsharp.net | |
open canopy | |
open runner | |
let switchTo b = browser <- b | |
let index = "http://dry-peak-5299.herokuapp.com/" | |
let createGame = ".nav li a" | |
let cardCzar = "#notificationCardCzar" | |
let waiting = "#notificationWaitingOnRound" | |
let join = "#availableGames div a" | |
let selectACard = "#notificationSelectCard" | |
let select = ".select-card" | |
let nextRound = "#buttonNextRound a" | |
let points = "#pointsValue" | |
let playFirstCard _ = | |
selectACard == "select a card to play" | |
click select | |
select *= "selected" | |
let tile (browsers : OpenQA.Selenium.IWebDriver list) = | |
let h = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height; | |
let w = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width; | |
let count = browsers.Length | |
let maxWidth = w / count | |
let rec setSize (browsers : OpenQA.Selenium.IWebDriver list) c = | |
match browsers with | |
| [] -> () | |
| b :: tail -> | |
b.Manage().Window.Size <- new System.Drawing.Size(maxWidth,h); | |
b.Manage().Window.Position <- new System.Drawing.Point((maxWidth * c),0); | |
setSize tail (c + 1) | |
setSize browsers 0 | |
let mutable browsers = [] | |
let start2 b = | |
start b | |
browsers <- browsers @ [browser] | |
let quit2 browser = | |
match box browser with | |
| :? OpenQA.Selenium.IWebDriver as b -> b.Close() | |
| _ -> browsers |> List.iter (fun b -> b.Close()) | |
start2 firefox | |
let player1 = browser | |
start2 firefox | |
let player2 = browser | |
start2 firefox | |
let player3 = browser | |
start2 firefox | |
let player4 = browser | |
tile [player1; player2; player3; player4] | |
test (fun _ -> | |
describe "create a new game and wait" | |
switchTo player1 | |
url index | |
click createGame | |
waiting == "waiting on round to start") | |
test (fun _ -> | |
describe "join existing game and wait" | |
switchTo player2 | |
url index | |
click join | |
waiting == "waiting on round to start") | |
test (fun _ -> | |
describe "join existing game and wait" | |
switchTo player3 | |
url index | |
click join | |
waiting == "waiting on round to start") | |
test (fun _ -> | |
describe "join existing game as last player and play" | |
switchTo player4 | |
url index | |
click join) | |
test(fun _ -> | |
describe "player 2 picks a card" | |
switchTo player2 | |
playFirstCard ()) | |
test(fun _ -> | |
describe "player 3 picks a card" | |
switchTo player3 | |
playFirstCard ()) | |
test(fun _ -> | |
describe "player 4 picks a card" | |
switchTo player4 | |
playFirstCard ()) | |
test(fun _ -> | |
describe "player 1 is czar and chooses card" | |
switchTo player1 | |
click select | |
describe "player 1 starts next round" | |
click nextRound) | |
test(fun _ -> | |
switchTo player2 | |
describe "player 2 wins" | |
points == "1" | |
describe "player 2 starts next round" | |
click nextRound) | |
test(fun _ -> | |
switchTo player3 | |
describe "player 3 loses" | |
points == "0" | |
describe "player 3 starts next round" | |
click nextRound) | |
test(fun _ -> | |
switchTo player4 | |
describe "player 4 loses" | |
points == "0" | |
describe "player 4 starts next round" | |
click nextRound) | |
test(fun _ -> | |
switchTo player2 | |
describe "player 2 is the czar" | |
cardCzar == "you are the card czar") | |
run () | |
quit2 () | |
System.Console.ReadLine(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment