Exemplo n.º 1
0
        public void List_ConnectionFound_SetsModelAndReturnsView()
        {
            // setup
            var currentUser = new UserIdentity()
            {
                Id = Guid.NewGuid(), UserName = "******"
            };
            var browser      = CreateBrowser(currentUser);
            var connectionId = Guid.NewGuid();
            int count        = new Random().Next(5, 20);

            ConnectionModel connection = new ConnectionModel()
            {
                Id   = connectionId,
                Host = "myserver"
            };

            _userStore.GetConnection(connectionId).Returns(connection);

            List <UIWorkflow> workflows = new List <UIWorkflow>();

            for (int i = 0; i < count; i++)
            {
                UIWorkflow wf = new UIWorkflow();
                wf.Id           = Guid.NewGuid();
                wf.WorkflowType = typeof(UIWorkflow).FullName;
                workflows.Add(wf);
            }
            _workflowInfoService.GetIncompleteWorkflows(connection, 50).Returns(workflows);

            // execute
            var response = browser.Post(Actions.Store.List, (with) =>
            {
                with.HttpRequest();
                with.FormsAuth(currentUser.Id, new Nancy.Authentication.Forms.FormsAuthenticationConfiguration());
                with.FormValue("ConnectionId", connectionId.ToString());
                with.FormValue("WorkflowCount", "10");
            });

            // assert
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual("text/html", response.ContentType);

            // SUCKS - for some reason this view throws a reference exception trying to load
            // Stateless.WorkflowEngine which is handled in the app with the config file.  Not sure
            // how to do this programatically so leaving this test for now...
            // Adding the assembly to the test RazorConfiguration didn't help and broke other tests....

            //string responseBody = response.Body.AsString();
            //response.Body["table"].ShouldExistOnce();

            //response.Body["td"]
            //    .ShouldExistExactly(count);
        }
Exemplo n.º 2
0
        public dynamic List()
        {
            var model       = this.Bind <WorkflowListModel>();
            var currentUser = _userStore.GetUser(this.Context.CurrentUser.UserName);

            // get the connection and load the workflows
            ConnectionModel connection = _userStore.GetConnection(model.ConnectionId);

            if (connection == null)
            {
                return(this.Response.AsJson(new { Message = "No connection found matching the supplied id" }, HttpStatusCode.NotFound));
                //throw new Exception("No connection found matching the supplied id.");
            }

            IEnumerable <UIWorkflow> workflows = _workflowInfoService.GetIncompleteWorkflows(connection, model.WorkflowCount);

            WorkflowListViewModel viewModel = new WorkflowListViewModel();

            viewModel.ConnectionId = connection.Id;
            viewModel.Workflows.AddRange(workflows);

            return(this.View[Views.Store.ListPartial, viewModel]);
        }