Beispiel #1
0
        public void ShouldHandleFromManagerToTeamApproveAndModifyTechApprover()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 //databaseActorId,
                                                 //networkShareActorId
                                             });

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                accessReq.EditWorkflow(managerUserId, new List<int>()
                                             {
                                                 teamApprovalActorId,
                                                 //windowsServerActorId,
                                                 databaseActorId,
                                                 //networkShareActorId
                                             });

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                verifyWorkflowTransition(wfs[0], WorkflowState.Pending_Approval, WorkflowState.Approved);

                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                verifyWorkflowTransition(wfs[0], WorkflowState.Pending_Approval, WorkflowState.Approved);

                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                verifyWorkflowTransition(wfs[0], WorkflowState.Not_Active, WorkflowState.Pending_Approval);
                Assert.IsTrue(wfs[0].actorId == databaseActorId);
            }
        }
Beispiel #2
0
        public void ShouldHandleCreateSDTicket()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 //databaseActorId,
                                                 //networkShareActorId
                                             });

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get technical approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // create SD ticket
                accessReq.CreateServiceDeskTicket();

                // For dev:
                // login to to http://awhdht02.devapollogrp.edu/CAisd/pdmweb.exe
                // sign in as svc_cap/S31H9D&amp;2j6
                // look at Change Orders/Unassinged/all

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Provisioning).completedDate == null);
                Assert.IsNotNull(req.ticketNumber);

            }
        }
Beispiel #3
0
        public void ShouldHandleFinalizeRequestWithSDticket()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 //databaseActorId,
                                                 //networkShareActorId
                                             });

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get technical approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // create SD ticket
                //accessReq.CreateServiceDeskTicket();

                // finalize it
                accessReq.FinalizeRequest();

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                //verifyWorkflowStateComplete(wfs[0], WorkflowState.Pending_Provisioning);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Closed_Completed);
                Assert.IsTrue(req.statusEnum == (byte)RequestState.Closed);
            }
        }
Beispiel #4
0
        public void ShouldHandleAbandonInPendingTechApprovalState()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 //databaseActorId,
                                                 //networkShareActorId
                                             });

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get technical approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                accessReq.NoAccess(WorkflowAction.Abandon, "Reach Max Overdue");
            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                Assert.IsTrue(req.statusEnum == (byte)RequestState.Closed);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Closed_Abandon);
                verifyWorkflowComment(wfs[0], CommentsType.Abandon);
            }
        }
Beispiel #5
0
        public void ShouldHandleAIMCancelWhenRequestInRequestToChangeState()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 databaseActorId,
                                                 networkShareActorId
                                             });

                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);

                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Change);

                accessReq.NoAccess(WorkflowAction.Cancel, "Cancel it");

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);

                Assert.IsTrue(req.statusEnum == (byte)RequestState.Closed);
                verifyWorkflowState(wfs[0], WorkflowState.Closed_Cancelled);
                verifyWorkflowComment(wfs[0], CommentsType.Cancelled);

            }
        }
Beispiel #6
0
        public static void CompleteRequestApprovalCheck(int id)
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                //var twf = db.SNAP_Workflows.Single(w => w.pkId == id);
                var req = db.SNAP_Requests.Single(r => r.pkId == id);
                var accessReq = new AccessRequest(id);
                var accessTeamWF = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Workflow_Admin)[0];
                var mgrWF = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Manager)[0];
                var teamApproverWFs = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Team_Approver);
                var techApproverWFs = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Technical_Approver);

                // only manager in the approal wf
                if (teamApproverWFs.Count == 0 && techApproverWFs.Count == 0)
                {
                    // make sure manager has not outstanding approval
                    if (mgrWF.SNAP_Workflow_States.OrderByDescending(s => s.pkId).First().completedDate != null)
                    {
                        AccessRequest.stateTransition(ActorApprovalType.Workflow_Admin, accessTeamWF,
                                                      WorkflowState.Workflow_Created, WorkflowState.Approved);
                        Email.SendTaskEmail(EmailTaskType.TransitionToPendingProvisioning,
                                            ConfigurationManager.AppSettings["AIM-DG"], null, req.pkId,
                                            req.userDisplayName);
                    }
                }
                else
                {
                    // we may or may not have team approver in the wf, if we do make sure all team approvers are approved
                    var done = true;

                    foreach (var wf in teamApproverWFs)
                    {
                        if (wf.SNAP_Workflow_States.Count(s => s.completedDate != null && s.workflowStatusEnum == (byte) WorkflowState.Approved) == 1)
                        {
                            done = true;
                        }
                        else
                        {
                            done = false;
                            break;
                        }
                    }

                    // now check technical approvers
                    //wfs = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Technical_Approver);
                    var totalApproved = 0;
                    var state =
                        accessTeamWF.SNAP_Workflow_States.Single(
                            s => s.workflowStatusEnum == (byte) WorkflowState.Workflow_Created
                                 && s.completedDate == null);
                        // get lastest 'worflow created' for the workflowadmin state

                    foreach (var w in techApproverWFs)
                    {
                        var cnt = w.SNAP_Workflow_States.Count(
                            s => s.workflowStatusEnum == (byte) WorkflowState.Approved
                                 && s.completedDate != null
                                 && s.pkId >= state.pkId);
                        // only check approval for the latest iteration, ignore previously approved interateion

                        totalApproved += cnt;
                    }

                    if (totalApproved == techApproverWFs.Count && done)
                    {
                        AccessRequest.stateTransition(ActorApprovalType.Workflow_Admin, accessTeamWF,
                                                      WorkflowState.Workflow_Created, WorkflowState.Approved);

                        Email.SendTaskEmail(EmailTaskType.TransitionToPendingProvisioning,
                                            ConfigurationManager.AppSettings["AIM-DG"], null, req.pkId,
                                            req.userDisplayName);
                    }
                }

                db.SubmitChanges();
            }
        }
Beispiel #7
0
        public void ShouldCreateWorkflowByAccessTeamAndThenMakeModification()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId });
            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");

                var accessReq = new AccessRequest(req.pkId);

                accessReq.EditWorkflow(managerUserId, new List<int>() { windowsServerActorId, databaseActorId, networkShareActorId });
                //accessReq.CreateWorkflow(new List<int>() { managerActorId });

                var accessTeamWF = db.SNAP_Workflows.Single(x => x.requestId == req.pkId && x.actorId == accessTeamActorId);
                var accessTeamWFStates = db.SNAP_Workflow_States.Where(x => x.workflowId == accessTeamWF.pkId);
                foreach (var s in accessTeamWFStates)
                {
                    Console.WriteLine(s.workflowId + "," + s.workflowStatusEnum + "," + ((s.completedDate != null) ? s.completedDate.ToString() : "TBD"));
                }

                verifyWorkflowState(accessTeamWF, WorkflowState.Workflow_Created);
                var managerWF = db.SNAP_Workflows.Single(x => x.requestId == req.pkId && x.actorId == managerActorId);
                var managerWFStates = db.SNAP_Workflow_States.Where(x => x.workflowId == managerWF.pkId);
                foreach (var s in managerWFStates)
                {
                    Console.WriteLine(s.workflowId + "," + s.workflowStatusEnum + "," + ((s.completedDate != null) ? s.completedDate.ToString() : "TBD"));
                }
                verifyWorkflowStateComplete(managerWF, WorkflowState.Not_Active);
                verifyWorkflowState(managerWF, WorkflowState.Pending_Approval);

                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                Assert.IsTrue(wfs.Count == 0);

                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                Assert.IsTrue(wfs.Count == 3);

                foreach(var wf in wfs)
                {
                    verifyWorkflowState(wf, WorkflowState.Not_Active);
                }
            }
        }
Beispiel #8
0
        public void ShouldHandleTechicalApprovalDeniedRequest()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 databaseActorId,
                                                 networkShareActorId
                                             });

                // get manager approval
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get technical disapproval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Denied, "Bad!!!");

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Workflow_Created);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Closed_Denied);

                Assert.IsTrue(req.statusEnum == (byte)RequestState.Closed);
                var wf = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver)[0];
                Assert.IsTrue(wf.SNAP_Workflow_Comments.Count(c => c.commentTypeEnum == (byte)CommentsType.Denied) > 0);
                verifyWorkflowComment(wf, CommentsType.Denied);
            }
        }
Beispiel #9
0
        public void ShouldHandleUpdateCreateWorkFlowByRemovingTechApproval()
        {
            int goneWFid = 0;
            // set up for first request to change
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 //databaseActorId,
                                                 //networkShareActorId
                                             });

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(
                    wfs[0].SNAP_Workflow_States.Single(
                        s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);
                goneWFid = wfs[0].pkId;

                // get technical approval, but the last one request to change
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                //accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);
                //accessReq.WorkflowAck(wfs[1].pkId, WorkflowAction.Approved);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Change, "change it");

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);

                Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                //verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved);
                //verifyWorkflowStateComplete(wfs[1], WorkflowState.Approved);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Change_Requested);

                verifyWorkflowComment(wfs[0], CommentsType.Requested_Change);
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate == null);

            }

            // recreate wf
            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");

                var accessReq = new AccessRequest(req.pkId);

                accessReq.RequestChanged();
                accessReq.Ack();
                accessReq.CreateWorkflow(new List<int>()
                                         {
                                             managerActorId,
                                             //teamApprovalActorId,
                                             windowsServerActorId,
                                             //databaseActorId,
                                             //networkShareActorId
                                         });

                // get technical approval, but the last one request to change
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                Assert.IsTrue(wfs.Count == 1);

                /*
                var noSuchWorkflow = db.SNAP_Workflows.Where(w => w.actorId == teamApprovalActorId);
                Assert.IsTrue(noSuchWorkflow.Count() == 0);
                */

                var noSuchWorkflow = req.SNAP_Workflows.Where(w => w.actorId == teamApprovalActorId);
                Assert.IsTrue(noSuchWorkflow.Count() == 0);

                var noSuchWorkflowState = db.SNAP_Workflow_States.Where(s => s.workflowId == goneWFid);
                //var noSuchWorkflowState = reNAP_Workflow_States.Where(s => s.workflowId == goneWFid);
                Assert.IsTrue(noSuchWorkflowState.Count() == 0);

                var noSuchWorkflowComment = db.SNAP_Workflow_Comments.Where(c => c.workflowId == goneWFid);
                Assert.IsTrue(noSuchWorkflowComment.Count() == 0);

            }
        }
Beispiel #10
0
        public void ShouldHandleRemoveLastAproverAfterAllApproved()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db,new List<int>()
                                             {
                                                 managerActorId,
                                                 windowsServerActorId,
                                                 databaseActorId,
                                             });

                // get manager approval
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                accessReq.EditWorkflow(managerUserId, new List<int>() { databaseActorId });

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                verifyWorkflowTransition(wfs[0], WorkflowState.Workflow_Created, WorkflowState.Approved);
            }
        }
Beispiel #11
0
        public void ShouldHandleTeamApproverRequestToChange()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 databaseActorId,
                                                 networkShareActorId
                                             });

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approer request to change
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Change);

                /*
                accessReq.RequestChanged();
                */
            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);

                Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate != null);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Change_Requested);
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate == null);
                verifyWorkflowState(wfs[0], WorkflowState.Change_Requested);
            }
        }
Beispiel #12
0
        public void ShouldHandleRemoveInactiveApprovers()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                                           {
                                                               managerActorId,
                                                               windowsServerActorId,
                                                               databaseActorId,
                                                           });
            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);

                accessReq.EditWorkflow(managerUserId, new List<int>() { managerActorId });

                Assert.IsTrue(req.statusEnum == (byte) RequestState.Pending);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.OrderByDescending(s=>s.pkId).
                    First().workflowStatusEnum == (byte)WorkflowState.Workflow_Created);
            }
        }
Beispiel #13
0
        public void ShouldHandleFromManagerToTeamToLastTechicalRequestToChangeLoop()
        {
            // set up for first request to change
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 databaseActorId,
                                                 networkShareActorId
                                             });

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(
                    wfs[0].SNAP_Workflow_States.Single(
                        s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get technical approval, but the last one request to change
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);
                accessReq.WorkflowAck(wfs[1].pkId, WorkflowAction.Approved);
                accessReq.WorkflowAck(wfs[2].pkId, WorkflowAction.Change, "change it");

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);

                Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved);
                verifyWorkflowStateComplete(wfs[1], WorkflowState.Approved);
                verifyWorkflowStateComplete(wfs[2], WorkflowState.Change_Requested);

                verifyWorkflowComment(wfs[2], CommentsType.Requested_Change);
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate == null);

            }

            for (int i = 0; i < 5; i++)
                using (var db = new SNAPDatabaseDataContext())
                {
                    var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");

                    var accessReq = new AccessRequest(req.pkId);

                    accessReq.RequestChanged();
                    accessReq.Ack();
                    accessReq.CreateWorkflow(new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 //databaseActorId,
                                                 networkShareActorId
                                             });

                    var accessWF = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                    var state = accessWF[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Workflow_Created
                        && s.completedDate == null); // get lastest 'pending approval' for the workflowadmin state

                    // get manager approal
                    var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                    //Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                    accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                    Assert.IsTrue(
                        wfs[0].SNAP_Workflow_States.Count(
                            s => s.completedDate != null
                                && s.workflowStatusEnum == (byte)WorkflowState.Approved
                                && s.pkId > state.pkId) == 1);

                    // get team approval
                    wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);

                    accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                    Assert.IsTrue(
                            wfs[0].SNAP_Workflow_States.Count(
                                s => s.completedDate != null
                                    && s.workflowStatusEnum == (byte)WorkflowState.Approved
                                    && s.pkId > state.pkId) == 1);

                    var r = new Random();
                    //var last = r.Next(2);
                    var last = r.Next(1);
                    //var last = 0;
                    // get only one technical request to change
                    wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                    for (int x = 0; x <= last; x++)
                    {
                        accessReq.WorkflowAck(wfs[x].pkId, WorkflowAction.Approved);
                        Assert.IsTrue(
                            wfs[0].SNAP_Workflow_States.Count(
                                s => s.completedDate != null
                                    && s.workflowStatusEnum == (byte)WorkflowState.Approved
                                    && s.pkId > state.pkId) == 1);
                    }

                    accessReq.WorkflowAck(wfs[++last].pkId, WorkflowAction.Change, "change it");
                    Assert.IsTrue(
                            wfs[last].SNAP_Workflow_States.Count(
                                s => s.completedDate != null
                                    && s.workflowStatusEnum == (byte)WorkflowState.Change_Requested
                                    && s.pkId > state.pkId) == 1);

                    /*
                    Assert.IsTrue(accessWF[0].SNAP_Workflow_States.Single(
                                s => s.completedDate == null
                                    && s.workflowStatusEnum == (byte)WorkflowState.Change_Requested)
                                   == 1);
                     */

                }
        }
Beispiel #14
0
        public void ShouldHandleFromManagerToTeamToLastTechicalRequestToChange()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createAndAckAccessReq(db);
                var techApprovers = new List<int>() {
                                       windowsServerActorId,
                                       databaseActorId,
                                       networkShareActorId
                                    };
                var actorIds = new List<int>()
                                   {
                                       managerActorId,
                                       teamApprovalActorId,
                                   };
                actorIds.AddRange(techApprovers);
                accessReq.CreateWorkflow(actorIds);

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Manager);
                Assert.IsTrue(
                    wfs[0].SNAP_Workflow_States.Single(
                        s => s.workflowStatusEnum == (byte) WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                wfs = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get technical approval, but the last one request to change
                wfs = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Technical_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);
                techApprovers.Remove(wfs[0].actorId);
                accessReq.WorkflowAck(wfs[1].pkId, WorkflowAction.Approved);
                techApprovers.Remove(wfs[1].actorId);
                //accessReq.WorkflowAck(wfs[2].pkId, WorkflowAction.Change, "change it");
                accessReq.RequestToChange(techApprovers[0], "change it");

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);

                Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved);
                verifyWorkflowStateComplete(wfs[1], WorkflowState.Approved);
                verifyWorkflowStateComplete(wfs[2], WorkflowState.Change_Requested);

                //Assert.IsTrue(wfs[2].SNAP_Workflow_Comments.Count(c => c.commentTypeEnum == (byte) CommentsType.Requested_Change) ==
                //    1);
                verifyWorkflowComment(wfs[2], CommentsType.Requested_Change);
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate == null);

            }
        }
Beispiel #15
0
        public void ShouldHandleFromManagerToTeamOnly()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                             });

                // get manager approal
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Pending_Approval);
                verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved);

                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                verifyWorkflowState(wfs[0], WorkflowState.Pending_Approval);

                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin);
                Assert.IsTrue(
                    wfs[0].SNAP_Workflow_States.Count(
                        w => w.completedDate == null && w.workflowStatusEnum == (byte) WorkflowState.Workflow_Created) == 1);

            }
        }
Beispiel #16
0
        public void ShouldReturnWorkflowIdByFromRequestIDAndUsrId()
        {
            SNAP_Request req;
            SNAP_Workflow wf;
            AccessRequest accessReq;

            using (var db = new SNAPDatabaseDataContext())
            {
                req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");

                accessReq = new AccessRequest(req.pkId);
                accessReq.Ack();
                accessReq.CreateWorkflow(new List<int>() {managerActorId, teamApprovalActorId, windowsServerActorId,databaseActorId,networkShareActorId});

                //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, managerUserId) == managerActorId);
                Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, managerUserId) != 0);
                // they are not active approver yet

                //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, teamApprovalUserId) == 0);
                //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, WindowsServerUserId) == 0);

                wf = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Manager)[0];
                accessReq.WorkflowAck(wf.pkId, WorkflowAction.Approved);
            }

            using (var db = new SNAPDatabaseDataContext())
            {
                req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                // this is the only active approver
                //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, teamApprovalUserId) == teamApprovalActorId);
                Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, teamApprovalUserId) != 0);
                // this are not active approver
                //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, managerUserId) == 0);
                //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, WindowsServerUserId) == 0);
            }

            using (var db = new SNAPDatabaseDataContext())
            {
                req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                wf = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Team_Approver)[0];
                accessReq.WorkflowAck(wf.pkId, WorkflowAction.Approved);
            }

            using (var db = new SNAPDatabaseDataContext()) {
                // these are active approvers
                /*
                Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, WindowsServerUserId) == windowsServerActorId);
                Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, networkShareUserId) == networkShareActorId);
                Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, databaseUserId) == databaseActorId);
                */
                Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, WindowsServerUserId) != 0);
                Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, networkShareUserId) != 0);
                Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, databaseUserId) != 0);

                // there are not active approvers
                //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, managerUserId) == 0);
                //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, teamApprovalUserId) == 0);
            }
        }
Beispiel #17
0
        public void ShouldHandleFromManagerToTeamToAllTechicalApprove()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var accessReq = createTestWorkflow(db, new List<int>()
                                             {
                                                 managerActorId,
                                                 teamApprovalActorId,
                                                 windowsServerActorId,
                                                 databaseActorId,
                                                 networkShareActorId
                                             });

                // get manager approal
                //ystem.Threading.Thread.Sleep(90000);
                var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager);
                Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null);

                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get team approval
                //System.Threading.Thread.Sleep(90000);
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);

                // get all technical approval

                // !!! for individual test, please uncommnet it
                // !!! comment it out to save time

                //System.Threading.Thread.Sleep(90000);
                wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver);
                accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved);
                accessReq.WorkflowAck(wfs[1].pkId, WorkflowAction.Approved);
                accessReq.WorkflowAck(wfs[2].pkId, WorkflowAction.Approved);

            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);

                //var accessTeamWF = req.SNAP_Workflows.Single(w => w.actorId == 1); // actid = 1 => accessTeam
                var accessTeamWF = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin)[0]; // there is only on workflow admin
                var accessTeamState = accessTeamWF.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Workflow_Created);

                Assert.IsTrue(accessTeamState.completedDate != null);  // all technical approval received, complete it

                accessTeamState = accessTeamWF.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Approved);
                Assert.IsTrue(accessTeamState.completedDate == null);  // all technical approval received, complete it

                // make sure approving manager wf propergates notify and due date to final state
                var firstApprover = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver)[0];
                var firstApproverPendingState = firstApprover.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval);
                var firstApproverApproveState = firstApprover.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Approved);
                Assert.IsTrue(firstApproverPendingState.notifyDate == firstApproverApproveState.notifyDate);
                Assert.IsTrue(firstApproverPendingState.dueDate == firstApproverApproveState.dueDate);

            }
        }
Beispiel #18
0
        protected ApprovalWorkflow(int id)
        {
            Id = id;
            db = new SNAPDatabaseDataContext();

            wf = db.SNAP_Workflows.Single(w => w.pkId == Id);
            req = wf.SNAP_Request;
            accessReq = new AccessRequest(req.pkId);
            accessTeamWF = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin)[0];
        }