public void GetWorkflowStoreInfo_ModelIsNull_ThrowsException()
        {
            TestDelegate del = () => _workflowInfoService.GetWorkflowStoreInfo(null);

            // assert
            Assert.Throws <ArgumentNullException>(del);
        }
Ejemplo n.º 2
0
        public dynamic Info()
        {
            var id = Request.Form["id"];
            //System.Threading.Thread.Sleep(2000);  // useful for testing
            // load the connections for the current user
            var conn = _userStore.GetConnection(id);

            if (conn == null)
            {
                var notFoundResult = new { Error = "Connection not found" };
                return(this.Response.AsJson(notFoundResult, HttpStatusCode.NotFound));
            }

            ConnectionInfoViewModel infoModel = _workflowInfoService.GetWorkflowStoreInfo(conn);

            return(this.Response.AsJson <ConnectionInfoViewModel>(infoModel));
        }
Ejemplo n.º 3
0
        public void Info_ConnectionFound_ReturnsConnectionInfo()
        {
            // setup
            var currentUser = new UserIdentity()
            {
                Id = Guid.NewGuid(), UserName = "******"
            };

            currentUser.Claims = new string[] { Claims.ConnectionDelete };
            var browser      = CreateBrowser(currentUser);
            var connectionId = Guid.NewGuid();

            ConnectionModel conn = new ConnectionModel();

            conn.Id = connectionId;
            _userStore.GetConnection(connectionId).Returns(conn);

            Random r = new Random();
            ConnectionInfoViewModel infoViewModel = new ConnectionInfoViewModel();

            infoViewModel.ActiveCount    = r.Next(1, 10);
            infoViewModel.SuspendedCount = r.Next(11, 20);
            infoViewModel.CompleteCount  = r.Next(100, 1000);
            _workflowStoreService.GetWorkflowStoreInfo(conn).Returns(infoViewModel);

            // execute
            var response = browser.Post(Actions.Connection.Info, (with) =>
            {
                with.HttpRequest();
                with.FormsAuth(currentUser.Id, new Nancy.Authentication.Forms.FormsAuthenticationConfiguration());
                with.FormValue("id", connectionId.ToString());
            });

            // assert
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);

            _workflowStoreService.Received(1).GetWorkflowStoreInfo(conn);

            ConnectionInfoViewModel result = JsonConvert.DeserializeObject <ConnectionInfoViewModel>(response.Body.AsString());

            Assert.AreEqual(infoViewModel.ActiveCount, result.ActiveCount);
            Assert.AreEqual(infoViewModel.SuspendedCount, result.SuspendedCount);
            Assert.AreEqual(infoViewModel.CompleteCount, result.CompleteCount);
        }