예제 #1
0
        public void DsfDataObject_Clone_NormalClone_FullDuplicationForProperties()
        {
            var executingUser = new Mock <IPrincipal>().Object;
            //------------Setup for test--------------------------
            var            wfInstanceID = Guid.NewGuid();
            IDSFDataObject dataObject   = new DsfDataObject(string.Empty, Guid.NewGuid(), "<x>1</x>");

            dataObject.BookmarkExecutionCallbackID = Guid.NewGuid();
            dataObject.CurrentBookmarkName         = "def";
            dataObject.DataList                               = new StringBuilder("<x/>");
            dataObject.DataListID                             = Guid.NewGuid();
            dataObject.DatalistInMergeDepth                   = enTranslationDepth.Data;
            dataObject.DatalistInMergeID                      = Guid.NewGuid();
            dataObject.DatalistInMergeType                    = enDataListMergeTypes.Union;
            dataObject.DatalistOutMergeDepth                  = enTranslationDepth.Data;
            dataObject.DatalistOutMergeFrequency              = DataListMergeFrequency.Always;
            dataObject.DatalistOutMergeID                     = Guid.NewGuid();
            dataObject.DatalistOutMergeType                   = enDataListMergeTypes.Union;
            dataObject.DebugSessionID                         = Guid.NewGuid();
            dataObject.EnvironmentID                          = Guid.NewGuid();
            dataObject.VersionNumber                          = 1;
            dataObject.ExecutionCallbackID                    = Guid.NewGuid();
            dataObject.ExecutionOrigin                        = ExecutionOrigin.Debug;
            dataObject.ExecutingUser                          = executingUser;
            dataObject.ExecutionOriginDescription             = "xxx";
            dataObject.ForceDeleteAtNextNativeActivityCleanup = true;
            dataObject.IsDataListScoped                       = false;
            dataObject.IsDebug                  = true;
            dataObject.IsFromWebServer          = true;
            dataObject.IsOnDemandSimulation     = true;
            dataObject.NumberOfSteps            = 2;
            dataObject.OriginalInstanceID       = Guid.NewGuid();
            dataObject.ParentInstanceID         = "1211";
            dataObject.ParentServiceName        = "xxx";
            dataObject.ParentThreadID           = 2;
            dataObject.ParentWorkflowInstanceId = "1233";
            dataObject.RawPayload               = new StringBuilder("<raw>a</raw>");
            dataObject.RemoteDebugItems         = new List <IDebugState>();
            dataObject.RemoteInvoke             = false;
            dataObject.RemoteInvokeResultShape  = new StringBuilder("<x/>");
            dataObject.RemoteInvokerID          = "999";
            dataObject.RemoteServiceType        = "NA";
            dataObject.ResourceID               = Guid.NewGuid();
            dataObject.ReturnType               = EmitionTypes.XML;
            dataObject.ServerID                 = Guid.NewGuid();
            dataObject.ServiceName              = "xxx";
            dataObject.WorkflowInstanceId       = wfInstanceID;
            dataObject.WorkflowResumeable       = false;
            dataObject.ParentID                 = Guid.NewGuid();
            dataObject.WorkspaceID              = Guid.NewGuid();
            dataObject.ClientID                 = Guid.NewGuid();
            dataObject.RunWorkflowAsync         = true;
            dataObject.IsDebugNested            = true;
            dataObject.ForEachNestingLevel      = 3;
            dataObject.StopExecution            = false;
            dataObject.IsServiceTestExecution   = true;
            dataObject.TestName                 = "Test 1";
            dataObject.IsDebugFromWeb           = true;
            dataObject.SourceResourceID         = Guid.NewGuid();
            dataObject.IsSubExecution           = true;
            dataObject.ServiceTest              = new ServiceTestModelTO {
                TestName = "Test Mock"
            };
            dataObject.StateNotifier = new Mock <IStateNotifier>().Object;
            dataObject.Settings      = new Dev2WorkflowSettingsTO {
                KeepLogsForDays = 999
            };
            var threadsToDispose = new Dictionary <int, List <Guid> >();
            var guidList         = new List <Guid> {
                Guid.NewGuid()
            };

            threadsToDispose.Add(3, guidList);
            dataObject.ThreadsToDispose = threadsToDispose;
            dataObject.AuthCache        = new ConcurrentDictionary <(IPrincipal, Dev2.Common.Interfaces.Enums.AuthorizationContext, string), bool>();

            //------------Execute Test---------------------------
            var clonedObject = dataObject.Clone();

            //------------Assert Results-------------------------

            // check counts, then check values
            var properties = typeof(IDSFDataObject).GetProperties();

            Assert.AreEqual(72, properties.Length);

            // now check each value to ensure it transfered
            Assert.AreEqual(dataObject.BookmarkExecutionCallbackID, clonedObject.BookmarkExecutionCallbackID);
            Assert.AreEqual(dataObject.CurrentBookmarkName, clonedObject.CurrentBookmarkName);
            Assert.AreEqual(dataObject.DataList, clonedObject.DataList);
            Assert.AreEqual(dataObject.DataListID, clonedObject.DataListID);
            Assert.AreEqual(dataObject.DatalistInMergeDepth, clonedObject.DatalistInMergeDepth);
            Assert.AreEqual(dataObject.DatalistInMergeID, clonedObject.DatalistInMergeID);
            Assert.AreEqual(dataObject.DatalistInMergeType, clonedObject.DatalistInMergeType);
            Assert.AreEqual(dataObject.DatalistOutMergeDepth, clonedObject.DatalistOutMergeDepth);
            Assert.AreEqual(dataObject.DatalistOutMergeFrequency, clonedObject.DatalistOutMergeFrequency);
            Assert.AreEqual(dataObject.DatalistOutMergeID, clonedObject.DatalistOutMergeID);
            Assert.AreEqual(dataObject.DatalistOutMergeType, clonedObject.DatalistOutMergeType);
            Assert.AreEqual(dataObject.DebugSessionID, clonedObject.DebugSessionID);
            Assert.AreEqual(dataObject.EnvironmentID, clonedObject.EnvironmentID);
            Assert.AreEqual(dataObject.VersionNumber, clonedObject.VersionNumber);
            Assert.AreEqual(dataObject.ExecutingUser, clonedObject.ExecutingUser);
            Assert.AreEqual(dataObject.ExecutionCallbackID, clonedObject.ExecutionCallbackID);
            Assert.AreEqual(dataObject.ExecutionOrigin, clonedObject.ExecutionOrigin);
            Assert.AreEqual(dataObject.ExecutionOriginDescription, clonedObject.ExecutionOriginDescription);
            Assert.AreEqual(dataObject.ForceDeleteAtNextNativeActivityCleanup, clonedObject.ForceDeleteAtNextNativeActivityCleanup);
            Assert.AreEqual(dataObject.IsDataListScoped, clonedObject.IsDataListScoped);
            Assert.AreEqual(dataObject.IsDebug, clonedObject.IsDebug);
            Assert.AreEqual(dataObject.IsFromWebServer, clonedObject.IsFromWebServer);
            Assert.AreEqual(dataObject.IsOnDemandSimulation, clonedObject.IsOnDemandSimulation);
            Assert.AreEqual(dataObject.IsRemoteInvoke, clonedObject.IsRemoteInvoke);
            Assert.AreEqual(dataObject.IsRemoteInvokeOverridden, clonedObject.IsRemoteInvokeOverridden);
            Assert.AreEqual(dataObject.NumberOfSteps, clonedObject.NumberOfSteps);
            Assert.AreEqual(dataObject.OriginalInstanceID, clonedObject.OriginalInstanceID);
            Assert.AreEqual(dataObject.ParentInstanceID, clonedObject.ParentInstanceID);
            Assert.AreEqual(dataObject.ParentServiceName, clonedObject.ParentServiceName);
            Assert.AreEqual(dataObject.ParentThreadID, clonedObject.ParentThreadID);
            Assert.AreEqual(dataObject.ParentWorkflowInstanceId, clonedObject.ParentWorkflowInstanceId);
            Assert.AreEqual(dataObject.RawPayload, clonedObject.RawPayload);
            Assert.AreEqual(dataObject.RemoteDebugItems, clonedObject.RemoteDebugItems);
            Assert.AreEqual(dataObject.RemoteInvoke, clonedObject.RemoteInvoke);
            Assert.AreEqual(dataObject.RemoteNonDebugInvoke, clonedObject.RemoteNonDebugInvoke);
            Assert.AreEqual(dataObject.RemoteInvokeResultShape, clonedObject.RemoteInvokeResultShape);
            Assert.AreEqual(dataObject.RemoteInvokerID, clonedObject.RemoteInvokerID);
            Assert.AreEqual(dataObject.RemoteServiceType, clonedObject.RemoteServiceType);
            Assert.AreEqual(dataObject.ResourceID, clonedObject.ResourceID);
            Assert.AreEqual(dataObject.ReturnType, clonedObject.ReturnType);
            Assert.AreEqual(dataObject.ServerID, clonedObject.ServerID);
            Assert.AreEqual(dataObject.ClientID, clonedObject.ClientID);
            Assert.AreEqual(dataObject.ServiceName, clonedObject.ServiceName);
            Assert.AreEqual(dataObject.WorkflowInstanceId, clonedObject.WorkflowInstanceId);
            Assert.AreEqual(dataObject.WorkflowResumeable, clonedObject.WorkflowResumeable);
            Assert.AreEqual(dataObject.WorkspaceID, clonedObject.WorkspaceID);
            Assert.AreEqual(dataObject.ThreadsToDispose, clonedObject.ThreadsToDispose);
            Assert.AreEqual(dataObject.ParentID, clonedObject.ParentID);
            Assert.AreEqual(dataObject.RunWorkflowAsync, clonedObject.RunWorkflowAsync);
            Assert.AreEqual(dataObject.IsDebugNested, clonedObject.IsDebugNested);
            Assert.AreEqual(dataObject.ForEachNestingLevel, clonedObject.ForEachNestingLevel);
            Assert.AreEqual(dataObject.StopExecution, clonedObject.StopExecution);
            Assert.AreEqual(dataObject.SourceResourceID, clonedObject.SourceResourceID);
            Assert.AreEqual(dataObject.TestName, clonedObject.TestName);
            Assert.AreEqual(dataObject.IsServiceTestExecution, clonedObject.IsServiceTestExecution);
            Assert.AreEqual(dataObject.IsDebugFromWeb, clonedObject.IsDebugFromWeb);
            Assert.AreNotEqual(dataObject.ServiceTest, clonedObject.ServiceTest);
            Assert.AreEqual(dataObject.ServiceTest.TestName, clonedObject.ServiceTest.TestName);
            Assert.AreEqual(dataObject.IsSubExecution, clonedObject.IsSubExecution);
            Assert.AreEqual(dataObject.WebUrl, clonedObject.WebUrl);
            Assert.AreEqual(dataObject.QueryString, clonedObject.QueryString);
            Assert.AreEqual(dataObject.ExecutingUser, clonedObject.ExecutingUser);
            Assert.AreEqual(dataObject.StateNotifier, clonedObject.StateNotifier);
            Assert.AreNotEqual(dataObject.Settings, clonedObject.Settings);
            Assert.AreEqual(dataObject.Settings.KeepLogsForDays, clonedObject.Settings.KeepLogsForDays);
            Assert.AreNotEqual(dataObject.AuthCache, clonedObject.AuthCache);
            Assert.AreEqual(dataObject.ExecutionException, clonedObject.ExecutionException);
        }
예제 #2
0
        public void DsfDataObject_Clone_NormalClone_FullDuplicationForProperties()
        {
            //------------Setup for test--------------------------
            IDSFDataObject dataObject   = new DsfDataObject(string.Empty, Guid.NewGuid(), "<x>1</x>");
            Guid           wfInstanceID = Guid.NewGuid();

            dataObject.BookmarkExecutionCallbackID = Guid.NewGuid();
            dataObject.CurrentBookmarkName         = "def";
            dataObject.DataList                  = new StringBuilder("<x/>");
            dataObject.DataListID                = Guid.NewGuid();
            dataObject.DatalistInMergeDepth      = enTranslationDepth.Data;
            dataObject.DatalistInMergeID         = Guid.NewGuid();
            dataObject.DatalistInMergeType       = enDataListMergeTypes.Union;
            dataObject.DatalistOutMergeDepth     = enTranslationDepth.Data;
            dataObject.DatalistOutMergeFrequency = DataListMergeFrequency.Always;
            dataObject.DatalistOutMergeID        = Guid.NewGuid();
            dataObject.DatalistOutMergeType      = enDataListMergeTypes.Union;
            dataObject.DebugSessionID            = Guid.NewGuid();
            dataObject.EnvironmentID             = Guid.NewGuid();
            //   dataObject.Errors = new ErrorResultTO();
            //   dataObject.Errors.AddError("my error");
            dataObject.ExecutionCallbackID                    = Guid.NewGuid();
            dataObject.ExecutionOrigin                        = ExecutionOrigin.Debug;
            dataObject.ExecutionOriginDescription             = "xxx";
            dataObject.ForceDeleteAtNextNativeActivityCleanup = true;
            dataObject.IsDataListScoped                       = false;
            dataObject.IsDebug                  = true;
            dataObject.IsFromWebServer          = true;
            dataObject.IsOnDemandSimulation     = true;
            dataObject.NumberOfSteps            = 2;
            dataObject.OriginalInstanceID       = Guid.NewGuid();
            dataObject.ParentInstanceID         = "1211";
            dataObject.ParentServiceName        = "xxx";
            dataObject.ParentThreadID           = 2;
            dataObject.ParentWorkflowInstanceId = "1233";
            dataObject.RawPayload               = new StringBuilder("<raw>a</raw>");
            dataObject.RemoteDebugItems         = new List <IDebugState>();
            dataObject.RemoteInvoke             = false;
            dataObject.RemoteInvokeResultShape  = new StringBuilder("<x/>");
            dataObject.RemoteInvokerID          = "999";
            dataObject.RemoteServiceType        = "NA";
            dataObject.ResourceID               = Guid.NewGuid();
            dataObject.ReturnType               = EmitionTypes.XML;
            dataObject.ServerID                 = Guid.NewGuid();
            dataObject.ServiceName              = "xxx";
            dataObject.WorkflowInstanceId       = wfInstanceID;
            dataObject.WorkflowResumeable       = false;
            dataObject.ParentID                 = Guid.NewGuid();
            dataObject.WorkspaceID              = Guid.NewGuid();
            dataObject.ClientID                 = Guid.NewGuid();
            dataObject.RunWorkflowAsync         = true;
            dataObject.IsDebugNested            = true;
            dataObject.ForEachNestingLevel      = 3;
            var         threadsToDispose = new Dictionary <int, List <Guid> >();
            List <Guid> guidList         = new List <Guid> {
                Guid.NewGuid()
            };

            threadsToDispose.Add(3, guidList);
            dataObject.ThreadsToDispose = threadsToDispose;

            //------------Execute Test---------------------------
            IDSFDataObject clonedObject = dataObject.Clone();

            //------------Assert Results-------------------------

            // check counts, then check values
            var properties = typeof(IDSFDataObject).GetProperties();

            Assert.AreEqual(56, properties.Length);

            // now check each value to ensure it transfered
            Assert.AreEqual(dataObject.BookmarkExecutionCallbackID, clonedObject.BookmarkExecutionCallbackID);
            Assert.AreEqual(dataObject.CurrentBookmarkName, clonedObject.CurrentBookmarkName);
            Assert.AreEqual(dataObject.DataList, clonedObject.DataList);
            Assert.AreEqual(dataObject.DataListID, clonedObject.DataListID);
            Assert.AreEqual(dataObject.DatalistInMergeDepth, clonedObject.DatalistInMergeDepth);
            Assert.AreEqual(dataObject.DatalistInMergeID, clonedObject.DatalistInMergeID);
            Assert.AreEqual(dataObject.DatalistInMergeType, clonedObject.DatalistInMergeType);
            Assert.AreEqual(dataObject.DatalistOutMergeDepth, clonedObject.DatalistOutMergeDepth);
            Assert.AreEqual(dataObject.DatalistOutMergeFrequency, clonedObject.DatalistOutMergeFrequency);
            Assert.AreEqual(dataObject.DatalistOutMergeID, clonedObject.DatalistOutMergeID);
            Assert.AreEqual(dataObject.DatalistOutMergeType, clonedObject.DatalistOutMergeType);
            Assert.AreEqual(dataObject.DebugSessionID, clonedObject.DebugSessionID);
            Assert.AreEqual(dataObject.EnvironmentID, clonedObject.EnvironmentID);
            //        Assert.AreEqual(dataObject.Errors, clonedObject.Errors);
            Assert.AreEqual(dataObject.ExecutingUser, clonedObject.ExecutingUser);
            Assert.AreEqual(dataObject.ExecutionCallbackID, clonedObject.ExecutionCallbackID);
            Assert.AreEqual(dataObject.ExecutionOrigin, clonedObject.ExecutionOrigin);
            Assert.AreEqual(dataObject.ExecutionOriginDescription, clonedObject.ExecutionOriginDescription);
            Assert.AreEqual(dataObject.ForceDeleteAtNextNativeActivityCleanup, clonedObject.ForceDeleteAtNextNativeActivityCleanup);
            Assert.AreEqual(dataObject.IsDataListScoped, clonedObject.IsDataListScoped);
            Assert.AreEqual(dataObject.IsDebug, clonedObject.IsDebug);
            Assert.AreEqual(dataObject.IsFromWebServer, clonedObject.IsFromWebServer);
            Assert.AreEqual(dataObject.IsOnDemandSimulation, clonedObject.IsOnDemandSimulation);
            Assert.AreEqual(dataObject.IsRemoteInvoke, clonedObject.IsRemoteInvoke);
            Assert.AreEqual(dataObject.IsRemoteInvokeOverridden, clonedObject.IsRemoteInvokeOverridden);
            Assert.AreEqual(dataObject.NumberOfSteps, clonedObject.NumberOfSteps);
            Assert.AreEqual(dataObject.OriginalInstanceID, clonedObject.OriginalInstanceID);
            Assert.AreEqual(dataObject.ParentInstanceID, clonedObject.ParentInstanceID);
            Assert.AreEqual(dataObject.ParentServiceName, clonedObject.ParentServiceName);
            Assert.AreEqual(dataObject.ParentThreadID, clonedObject.ParentThreadID);
            Assert.AreEqual(dataObject.ParentWorkflowInstanceId, clonedObject.ParentWorkflowInstanceId);
            Assert.AreEqual(dataObject.RawPayload, clonedObject.RawPayload);
            Assert.AreEqual(dataObject.RemoteDebugItems, clonedObject.RemoteDebugItems);
            Assert.AreEqual(dataObject.RemoteInvoke, clonedObject.RemoteInvoke);
            Assert.AreEqual(dataObject.RemoteNonDebugInvoke, clonedObject.RemoteNonDebugInvoke);
            Assert.AreEqual(dataObject.RemoteInvokeResultShape, clonedObject.RemoteInvokeResultShape);
            Assert.AreEqual(dataObject.RemoteInvokerID, clonedObject.RemoteInvokerID);
            Assert.AreEqual(dataObject.RemoteServiceType, clonedObject.RemoteServiceType);
            Assert.AreEqual(dataObject.ResourceID, clonedObject.ResourceID);
            Assert.AreEqual(dataObject.ReturnType, clonedObject.ReturnType);
            Assert.AreEqual(dataObject.ServerID, clonedObject.ServerID);
            Assert.AreEqual(dataObject.ClientID, clonedObject.ClientID);
            Assert.AreEqual(dataObject.ServiceName, clonedObject.ServiceName);
            Assert.AreEqual(dataObject.WorkflowInstanceId, clonedObject.WorkflowInstanceId);
            Assert.AreEqual(dataObject.WorkflowResumeable, clonedObject.WorkflowResumeable);
            Assert.AreEqual(dataObject.WorkspaceID, clonedObject.WorkspaceID);
            Assert.AreEqual(dataObject.ThreadsToDispose, clonedObject.ThreadsToDispose);
            Assert.AreEqual(dataObject.ParentID, clonedObject.ParentID);
            Assert.AreEqual(dataObject.RunWorkflowAsync, clonedObject.RunWorkflowAsync);
            Assert.AreEqual(dataObject.IsDebugNested, clonedObject.IsDebugNested);
            Assert.AreEqual(dataObject.ForEachNestingLevel, clonedObject.ForEachNestingLevel);
        }