Note that there are some explanatory texts on larger screens.

plurals
  1. POAm I writing my first MSpec specifications correctly?
    primarykey
    data
    text
    <p>I'm writing my first MSpec specifications and I wanted some guidance. I left the specs in the "pending" state, but the context is filled out. Are there any improvements to be made?</p> <p>For reference, this is the story and first scenario: </p> <pre><code>Story: "Blog admin logs in to the system" As a blog writer I want to be able to log in to my blog So that I can write posts and administer my blog Scenario: "Logs in from the login page" Given the user enters in correct credentials for a user in the system When the user clicks the "Login" button Then log the user in and redirect to the admin panel with a message stating that he logged in correctly </code></pre> <p>And the MSpec code (some parts snipped), notice that I had to alias the MSpec <code>It</code> delegate due to a conflict with <code>Moq.It</code>:</p> <pre><code>using MoqIt = Moq.It; using ThenIt = Machine.Specifications.It; [Subject("User tries logging in")] public class When_user_enters_valid_credentials : With_user_existing_in_membership { protected static ActionResult result; Because of = () =&gt; { result = loginController.Login(validUsername, validPassword); }; ThenIt should_log_the_user_in; ThenIt should_redirect_the_user_to_the_admin_panel; ThenIt should_show_message_confirming_successful_login; } public abstract class With_user_existing_in_membership { protected static Mock&lt;ISiteMembership&gt; membershipMock; protected static string validUsername; protected static string validPassword; protected static LoginController loginController; Establish context =()=&gt; { membershipMock = new Mock&lt;ISiteMembership&gt;(); validUsername = "ValidUsername"; validPassword = "ValidPassword"; //make sure it's treated as valid usernames and password membershipMock .Setup&lt;bool&gt;(m =&gt; m.Validate( MoqIt.Is&lt;string&gt;(s =&gt; s == validUsername), MoqIt.Is&lt;string&gt;(s =&gt; s == validPassword))) .Returns(true); loginController = new LoginController(membershipMock.Object); }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload