public void TestRemoveRolesShouldRemoveSpecificRoles()
        {
            var collection = _database.GetCollection <ProcessDefinitionPersistence>(MongoProcessDefinitionPersistenceService.CollectionName);
            IProcessDefinitionPersisnenceService service = InstService();

            AccountData[] accounts = new[]
            {
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "Underwriter",
                    SourceSystem = "ActiveDirectory"
                },
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "Modeler",
                    SourceSystem = "ActiveDirectory"
                },
            };

            OnCreateFlowWithAssociatedSecutityAccounts(service, accounts);
            Assert.AreEqual(1, collection.Count(pd => true));
            IReadOnlyList <ProcessDefinitionDigest> flows = service.LisAlltWorkflows();

            Assert.IsNotNull(flows);
            Assert.AreEqual(1, flows.Count);
            ProcessDefinitionDigest flow = flows.ElementAt(0);

            service.RemoveRoles(flow.Id, flow.Version, accounts[0]);
            var idFilter
                = Builders <ProcessDefinitionPersistence> .Filter.Eq(r => r.Id, flow.Id);

            ProcessDefinitionPersistence persistence = collection.FindSync(idFilter).FirstOrDefault();

            Assert.IsNotNull(persistence);
            Assert.IsNotNull(persistence.Accounts);
            Assert.AreEqual(1, persistence.Accounts.Count);
            Assert.AreEqual(accounts[1].Name, persistence.Accounts[0].Name);
        }
        /// <summary>
        /// Create persistent element
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="collection"></param>
        /// <param name="errors"></param>
        /// <param name="processDefinitionDigest"></param>
        /// <param name="nextStepId"></param>
        /// <returns></returns>
        private MongoProcessRuntimePersistence CreateMongoProcessRuntimePersistence(
            IProcessRuntime runtime,
            IPropertySetCollection collection,
            string nextStepId,
            List <string> errors,
            ProcessDefinitionDigest processDefinitionDigest)
        {
            var persistedCollection            = CreatePersistentPropertyCollection(runtime, collection);
            MongoProcessRuntimePersistence rtp = new MongoProcessRuntimePersistence
            {
                Id = runtime.Id,
                SuspendedStepId    = runtime.LastExecutedStep?.StepId,
                Status             = (int)runtime.State,
                LastUpdated        = DateTime.UtcNow,
                PropertyCollection = persistedCollection,
                DefinitionFlowId   = processDefinitionDigest.FlowId,
                DefinitionMd5      = processDefinitionDigest.Md5,
                NextStepId         = null,
                Errors             = errors
            };

            return(rtp);
        }