コード例 #1
0
        public void WhenLoggedInAsAUserCanOnlyLogoutAndViewMessage()
        {
            var workflow = new MessageWorkflow();

            LoginUser(workflow);

            var loginActionsAvailable = workflow.GetActions().Any(IsLogoutAction());

            Assert.That(loginActionsAvailable, Is.True);
            var viewMessageAvailable = workflow.GetActions().Any(IsViewMessageAction());

            Assert.That(viewMessageAvailable, Is.True);
        }
コード例 #2
0
        public void WhenAdminEditsMessageCanViewMessage()
        {
            var workflow = new MessageWorkflow();

            LoginAdministrator(workflow);

            var editMessageAction = (EditMessageAction)workflow.GetActions().First(IsEditMessageAction());

            const string helloWorld = "Hello World";

            editMessageAction.SetMessage(helloWorld);

            var viewMessageAction = (ViewMessageAction)workflow.GetActions().First(IsViewMessageAction());
            var messageRetrieved  = viewMessageAction.GetMessage();

            Assert.That(messageRetrieved, Is.EqualTo(helloWorld));
        }
コード例 #3
0
        private static void LoginUser(MessageWorkflow workflow)
        {
            var actions = workflow.GetActions();

            var firstAction = (LoginAction)actions.First(IsLoginAction());

            firstAction.Login(new LoginCredentials("User", "Password"));
        }
コード例 #4
0
        private static void LoginAdministrator(MessageWorkflow workflow)
        {
            var actions = workflow.GetActions();

            var firstAction = (LoginAction)actions.First();

            firstAction.Login(new LoginCredentials("Administrator", "Password"));
        }
コード例 #5
0
        public void TheFirstActionForMessageWorkflowIsLogin()
        {
            var workflow = new MessageWorkflow();
            var actions  = workflow.GetActions();

            var firstAction = actions.First();

            Assert.That(firstAction, Is.TypeOf <LoginAction>());
        }
コード例 #6
0
        public void LoggedInAdministratorCanEditTheMessage()
        {
            var workflow = new MessageWorkflow();

            LoginAdministrator(workflow);

            var editMessageAvalable = workflow.GetActions().Any(IsEditMessageAction());

            Assert.That(editMessageAvalable, Is.True);
        }
コード例 #7
0
        public void CanLoginToTheMessageWorkflowAsAnAdmin()
        {
            var workflow = new MessageWorkflow();

            LoginAdministrator(workflow);

            var loginActionsAvailable = workflow.GetActions().Any(IsLoginAction());

            Assert.That(loginActionsAvailable, Is.False);
        }
コード例 #8
0
        public void CanViewTheMessageOnceLoggedIn()
        {
            var workflow = new MessageWorkflow();

            LoginUser(workflow);

            var viewMessage = (ViewMessageAction)workflow.GetActions().First(IsViewMessageAction());

            var message = viewMessage.GetMessage();

            Assert.That(message, Is.EqualTo(string.Empty));
        }
コード例 #9
0
        public void AdminnCanLoginEditMessageLogoutAndUserCanLoginAndReadMessage()
        {
            var workflow = new MessageWorkflow();

            LoginAdministrator(workflow);

            var editMessageAction = (EditMessageAction)workflow.GetActions().First(IsEditMessageAction());

            const string helloWorld = "Hello World";

            editMessageAction.SetMessage(helloWorld);

            var logoutAction = (LogoutAction)workflow.GetActions().First(IsLogoutAction());

            logoutAction.Logout();

            LoginUser(workflow);
            var viewMessageAction = (ViewMessageAction)workflow.GetActions().First(IsViewMessageAction());
            var messageRetrieved  = viewMessageAction.GetMessage();

            Assert.That(messageRetrieved, Is.EqualTo(helloWorld));
        }