Ejemplo n.º 1
0
        public void ActivityMatrixWithNotifierTest()
        {
            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareActivityMatrixResourceDescriptor();

            IWfProcessDescriptor processDesp = ProcessHelper.GetDynamicProcessDesp(resource);

            IWfProcess process = ProcessHelper.StartupProcess(processDesp, new Dictionary <string, object>()
            {
                { "CostCenter", "1001" },
                { "PayMethod", "1" },
                { "Age", 30 }
            });

            Console.WriteLine(process.Activities.Count);

            WfOutputHelper.OutputMainStream(process);
            WfOutputHelper.OutputEveryActivities(process);

            Assert.AreEqual(5, process.Activities.Count);

            Assert.IsTrue(process.Descriptor.Activities["ND10"].EnterEventReceivers.Count > 0);
            Assert.IsTrue(process.Descriptor.Activities["ND20"].EnterEventReceivers.Count > 0);

            Assert.IsTrue(process.Descriptor.Activities["ND10"].LeaveEventReceivers.Count > 0);
            Assert.IsTrue(process.Descriptor.Activities["ND20"].LeaveEventReceivers.Count > 0);
        }
Ejemplo n.º 2
0
        public void FilterAndMergeNotMatchedActivityMatrixAndApprovalMatrixTest()
        {
            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName  = "CostCenter";
            queryParam.QueryValue = "1001";

            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareActivityMatrixResourceDescriptor();

            resource.Rows.ForEach(row => row.Values.FindByColumnName(SOARolePropertyDefinition.ActivityCodeColumn).Value = "NotMatched");

            SOARolePropertyRowCollection activityRows = resource.Rows.Query(queryParam);

            int originalActivityCount = activityRows.Count;

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            SOARolePropertyRowCollection approvalRows = approvalMatrix.Rows.Query(queryParam);

            int originalApprovalCount = approvalMatrix.PropertyDefinitions.Count - 1;

            activityRows.MergeApprovalMatrix(resource.PropertyDefinitions, approvalRows, approvalMatrix.PropertyDefinitions);

            activityRows.AssertAndOutputMatrixOperators();

            Assert.AreEqual(originalActivityCount + originalApprovalCount, activityRows.Count);
        }
Ejemplo n.º 3
0
        public void MergeMatchedOneActivityMatrixAndApprovalMatrixTest()
        {
            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareOneRowActivityMatrixResourceDescriptor();

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareOneRowApprovalMatrixResourceDescriptor();

            resource.MergeApprovalMatrix(approvalMatrix);

            Assert.AreEqual(approvalMatrix.PropertyDefinitions.Count - 1, resource.Rows.Count);

            resource.AssertAndOutputMatrixOperators();
        }
Ejemplo n.º 4
0
        public void AllReservedColumnsActivityMatrixQueryParamTest()
        {
            IWfProcessDescriptor processDesp = ProcessHelper.GetDynamicProcessDesp(ActivityMatrixHelper.PrepareReservedActivityMatrixResourceDescriptor());

            IWfProcess process = ProcessHelper.StartupProcess(processDesp, new Dictionary <string, object>());

            IWfActivityDescriptor normalActDesp         = processDesp.Activities["NormalActivity"];
            WfActivityMatrixResourceDescriptor resource = (WfActivityMatrixResourceDescriptor)normalActDesp.Resources[0];

            SOARoleContext context = SOARoleContext.CreateContext(resource.PropertyDefinitions, process);

            context.QueryParams.Output();
        }
Ejemplo n.º 5
0
        public void ActiveMatrixResourceSerializationTest()
        {
            WfActivityMatrixResourceDescriptor expected = ActivityMatrixHelper.PrepareDynamicActivityMatrixResourceDescriptor();

            string serializedData = SerializationHelper.SerializeObjectToString(expected, SerializationFormatterType.Binary);

            WfActivityMatrixResourceDescriptor actual = SerializationHelper.DeserializeStringToObject <WfActivityMatrixResourceDescriptor>(serializedData, SerializationFormatterType.Binary);

            Assert.AreEqual(expected.PropertyDefinitions.Count, actual.PropertyDefinitions.Count);
            Assert.AreEqual(expected.Rows.Count, actual.Rows.Count);

            Assert.AreEqual(expected.PropertyDefinitions.GetAllKeys().Count(), actual.PropertyDefinitions.GetAllKeys().Count());
        }
Ejemplo n.º 6
0
        public void MergeMatchedActivityMatrixAndApprovalMatrixTest()
        {
            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareActivityMatrixResourceDescriptor();

            int originalCount = resource.Rows.Count;

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            resource.MergeApprovalMatrix(approvalMatrix);

            Assert.AreEqual(originalCount, resource.Rows.Count);

            resource.AssertAndOutputMatrixOperators();
        }
Ejemplo n.º 7
0
        public void MergeNotMatchedOneActivityMatrixAndApprovalMatrixTest()
        {
            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareOneRowActivityMatrixResourceDescriptor();

            int originalCount = resource.Rows.Count;

            resource.Rows[0].Values.FindByColumnName(SOARolePropertyDefinition.ActivityCodeColumn).Value = "NotMatched";
            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareOneRowApprovalMatrixResourceDescriptor();

            resource.MergeApprovalMatrix(approvalMatrix);

            Assert.AreEqual(approvalMatrix.PropertyDefinitions.Count, resource.Rows.Count);

            resource.AssertAndOutputMatrixOperators();
        }
Ejemplo n.º 8
0
        public void ActiveMatrixResourceJsonSerializationTest()
        {
            WfActivityMatrixResourceDescriptor expected = ActivityMatrixHelper.PrepareActivityMatrixResourceDescriptor();

            WfConverterHelper.RegisterConverters();

            string serializedData = JSONSerializerExecute.Serialize(expected);

            Console.WriteLine(serializedData);

            WfActivityMatrixResourceDescriptor actual = JSONSerializerExecute.Deserialize <WfActivityMatrixResourceDescriptor>(serializedData);

            Assert.AreEqual(expected.PropertyDefinitions.Count, actual.PropertyDefinitions.Count);
            Assert.AreEqual(expected.Rows.Count, actual.Rows.Count);

            Assert.AreEqual(expected.PropertyDefinitions.GetAllKeys().Count(), actual.PropertyDefinitions.GetAllKeys().Count());
        }
Ejemplo n.º 9
0
        public void SameActivitySNActivityMatrixTest()
        {
            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareSameSNActivityMatrixResourceDescriptor();
            IWfProcessDescriptor processDesp            = ProcessHelper.GetDynamicProcessDesp(resource, string.Empty);

            IWfProcess process = ProcessHelper.StartupProcess(processDesp, new Dictionary <string, object>()
            {
                { "CostCenter", "1001" },
                { "PayMethod", "1" },
                { "Age", 30 }
            });

            Console.WriteLine(process.Activities.Count);

            WfOutputHelper.OutputMainStream(process);
            WfOutputHelper.OutputEveryActivities(process);

            Assert.AreEqual(4, process.Activities.Count);
        }
Ejemplo n.º 10
0
        public void ActivityMatrixWithDynamicActivityTest()
        {
            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareDynamicActivityMatrixResourceDescriptor();
            IWfProcessDescriptor processDesp            = ProcessHelper.GetDynamicProcessDesp(resource, string.Empty);

            IWfProcess process = ProcessHelper.StartupProcess(processDesp, new Dictionary <string, object>()
            {
                { "CostCenter", "1001" },
                { "PayMethod", "1" },
                { "Age", 30 },
                { "ReportLine", new IUser[] { OguObjectSettings.GetConfig().Objects["approver1"].User, OguObjectSettings.GetConfig().Objects["cfo"].User } }
            });

            Console.WriteLine(process.Activities.Count);

            WfOutputHelper.OutputMainStream(process);
            WfOutputHelper.OutputEveryActivities(process);

            Assert.AreEqual(7, process.Activities.Count);
        }
Ejemplo n.º 11
0
        public void MergeNotMatchedActivityMatrixAndApprovalMatrixProcessTest()
        {
            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            WfApprovalMatrixAdapter.Instance.Update(approvalMatrix);

            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareActivityMatrixResourceDescriptor();

            resource.Rows.ForEach(row => row.Values.FindByColumnName(SOARolePropertyDefinition.ActivityCodeColumn).Value = "NotMatched");

            IWfProcessDescriptor processDesp = ProcessHelper.GetDynamicProcessDesp(resource, approvalMatrix.ID);

            IWfProcess process = ProcessHelper.StartupProcess(processDesp, new Dictionary <string, object>()
            {
                { "CostCenter", "1001" },
                { "PayMethod", "1" },
                { "Age", 30 }
            });

            Console.WriteLine(process.Activities.Count);

            WfOutputHelper.OutputMainStream(process);
            WfOutputHelper.OutputEveryActivities(process);

            process.Activities.ForEach(act =>
            {
                if (act.Descriptor.ActivityType == WfActivityType.NormalActivity)
                {
                    if (act.Descriptor.Properties.GetValue("IsDynamic", false) == false)
                    {
                        Console.WriteLine(act.Descriptor.Name);
                        Assert.IsTrue(act.Descriptor.Name.IndexOf("审批") >= 0);
                    }
                }
            });

            Assert.AreEqual(8, process.Activities.Count);
        }
Ejemplo n.º 12
0
        public void FilterAndMergeMatchedActiveMatrixWithRoleAndApprovalMatrixTest()
        {
            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName  = "CostCenter";
            queryParam.QueryValue = "1002";

            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareActivityMatrixResourceDescriptor();

            SOARolePropertyRowCollection activityRows = resource.Rows.Query(queryParam);

            int originalCount = activityRows.Count;

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            SOARolePropertyRowCollection approvalRows = approvalMatrix.Rows.Query(queryParam);

            activityRows.MergeApprovalMatrix(resource.PropertyDefinitions, approvalRows, approvalMatrix.PropertyDefinitions);

            activityRows.AssertAndOutputMatrixOperators();

            Assert.AreEqual(3, activityRows.Count);
        }
Ejemplo n.º 13
0
        public void MergeActivityMatrixWithDynamicActivityAndApprovalMatrixTest()
        {
            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareDynamicActivityMatrixResourceDescriptor();

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            WfApprovalMatrixAdapter.Instance.Update(approvalMatrix);

            IWfProcessDescriptor processDesp = ProcessHelper.GetDynamicProcessDesp(resource, approvalMatrix.ID);

            IWfProcess process = ProcessHelper.StartupProcess(processDesp, new Dictionary <string, object>()
            {
                { "CostCenter", "1001" },
                { "PayMethod", "1" },
                { "Age", 30 },
                { "ReportLine", new IUser[] { OguObjectSettings.GetConfig().Objects["approver1"].User, OguObjectSettings.GetConfig().Objects["cfo"].User } }
            });

            Console.WriteLine(process.Activities.Count);

            WfOutputHelper.OutputMainStream(process);
            WfOutputHelper.OutputEveryActivities(process);
        }