7. Login
public class Login : ColumnFixture {
public string UserName { get; set; }
public string Password { get; set; }
public bool IsValid { get {
return User.Named[UserName].Password == Password;
}}
public DateTime LastLogged { get {
return User.Named[UserName].LastLogged;
}}
}
8. Row Fixture
|Top Ten Movies in Imdb |
|Rank|Rating|Title |Year|
|1 |9.1 |The Shawshank Redemption |1994|
|2 |9.1 |The Godfather |1972|
|3 |9.0 |The Godfather: Part II |1974|
|4 |8.9 |Il buono, il brutto, il cattivo. |1966|
|5 |8.9 |Pulp Fiction |1994|
|6 |8.8 |Schindler's List |1993|
|7 |8.8 |12 Angry Men |1957|
|8 |8.8 |One Flew Over the Cuckoo's Nest |1975|
|9 |8.8 |Star Wars: Episode V - The Empire Strikes Back|1980|
|10 |8.8 |The Dark Knight |2008|
9. Top Ten
public class TopTenMoviesInImdb : RowFixture {
public override object[] Query() {
return Movie.TopTenInImdb;
}
public override Type GetTargetClass() {
return typeof(Movie);
}
}
10. Flow Mode
|Help File Is Product Specific|
|Load Products|
|Help File should be|Products.pdf|
|Select|Webcams|
|check|Help File is|Webcams.pdf|
11. Help File Is Product Specific
public class HelpFileIsProductSpecific {
List<string> Products;
string SelectedProduct;
public void load_products() {
Products = new List<string> {
"Memory Cards", "Camcorders", "Webcams", "Lenses“
};
}
public void Select(string product) {
if (Products.Contains(product)) SelectedProduct = product;
}
public string help_file_is { get {
return SelectedProduct == null ?
"Products.pdf" : SelectedProduct + ".pdf";
}}
public bool help_file_should_be(string expectedHelpfile) {
return help_file_is.Equals(expectedHelpfile);
}
}
12. Mixed with Lists
|Oscars|
|The Best Picture nominees are|
|Title |
|Avatar |
|The Blind Side |
|District 9 |
|An Education |
|The Hurt Locker |
|Inglourious Basterds |
|Precious |
|A Serious Man |
|Up |
|Up in the Air |
13. Mixed with Column
|And the Oscar should go to |
|Title? |Director? |
|Inglourious Basterds|Quentin Tarantino|
14. Oscars
public class Oscars {
public List<Movie> The_Best_Picture_nominees_are() {
return Movie.OscarNominees;
}
public Fixture And_the_Oscar_should_go_to() {
var Winner = new ColumnFixture();
Winner.SetSystemUnderTest(Movie.Winner);
return Winner;
}
}
15. Switching SUT
!define EventId {7036}
!define Source {Service Control Manager}
|Service Controller|
|Start Service|aspnet_state|
|Stop Service |aspnet_state|
|with|new|Event Log|
|should contain entries in|System|log with|${Source}|source and|${EventId}|event id in the last|10|seconds|
|Message |
|The ASP.NET State Service service entered the running state. |
|The ASP.NET State Service service entered the stopped state. |
16. Event Log
public class ServiceControllerFixture {
public void StartService(string ServiceName) { ... }
public void StopService(string ServiceName) { ... }
}
public class EventLog {
public SubsetFixture should_contain_entries_in_log_with_source_and_eventId_in_the_last_seconds(
string LogName, string SourceName, long EventID, int Seconds) {
return new SubsetFixture(GetEventLogsFor(LogName, SourceName ...));
}
}
17. Free Text
![ User Login
The user credentials should be requested on the first run of Zunzun
The credentials should be stored with encrypted password
]!
![
Once recorded, the credentials should not be requested
An error message should be shown if the credentials are invalid
]!
18. Account Config
public class AccountConfig {
public bool The_user_credentials_should_be_requested_on_the_first_run_of_zunzun() {
return true;
}
public bool The_credentials_should_be_stored_with_encrypted_password() {
return true;
}
public bool Once_recorded_the_credentials_should_not_be_requested() {
return true;
}
public bool An_error_message_should_be_shown_if_the_credentials_are_invalid() {
return true;
}
}
19. Free Text
![ Tweeting Photos
Zunzun should allow to browse for the photo
upload it into a website that stores photos
and paste the url in the Tweet
]!
![
The url should not be shortened
and should be pasted at cursor position
]!
![ Uploading Photos with Multiple Services
It should work with these services
yfrog
twitpic
]!
20. Tweeting Photos
public class TweetingPhotos {
public bool Zunzun_should_allow_to_browse_for_the_photo() { return true; }
public bool upload_it_into_a_website_that_stores_photos() { return true; }
public bool and_paste_the_url_in_the_Tweet() { return true; }
public bool The_url_should_not_be_shortened() { return true; }
public bool and_should_be_pasted_at_cursor_position() { return true;}
}
public class UploadingPhotosWithMultipleServices : ConstraintFixture {
public bool It_should_work_with_these_services(string ServiceName) { return true; }
}