public void List_OnExecute_LoadsAllConnectionsForCurrentUser()
        {
            // setup
            var currentUser = new UserIdentity()
            {
                Id = Guid.NewGuid(), UserName = "******"
            };
            var browser = CreateBrowser(currentUser);

            int connectionCount = new Random().Next(3, 9);
            List <ConnectionModel> connections = new List <ConnectionModel>();

            for (var i = 0; i < connectionCount; i++)
            {
                connections.Add(new ConnectionModel());
            }
            _userStore.Connections.Returns(connections);

            // execute
            var response = browser.Get(Actions.Connection.List, (with) =>
            {
                with.HttpRequest();
                with.FormsAuth(currentUser.Id, new Nancy.Authentication.Forms.FormsAuthenticationConfiguration());
            });

            // assert
            _workflowStoreService.Received(connectionCount).PopulateWorkflowStoreInfo(Arg.Any <WorkflowStoreModel>());
        }
Пример #2
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);
        }