コード例 #1
0
        public WebsiteEditorViewModel(IWebActivity webActivity)
        {
            WebCommunication    = ImportService.GetExportValue <IWebCommunication>();
            FileNameProvider    = ImportService.GetExportValue <IFileNameProvider>();
            UserMessageProvider = ImportService.GetExportValue <IUserMessageProvider>();

            if (webActivity == null)
            {
                throw new ArgumentNullException("webActivity");
            }
            _webActivity   = webActivity;
            _layoutObjects = new ObservableCollection <ILayoutObjectViewModel>();

            _resource = webActivity.ResourceModel;

            InitializeWebResources();
            SetDefaultWebpage();
        }
コード例 #2
0
        public void WorkflowExecuted_Where_ExecutionStatusCallBackRegisteredAndDataListMergeRequested_Expected_DataMergedInAndOutOfWorkflow()
        {
            //
            // Create a reset event which is used to wait for callbacks form the server
            //
            ManualResetEventSlim resetEvent = new ManualResetEventSlim(false);

            //
            // Setup MEF context
            //
            ImportService.CurrentContext = CompositionInitializer.DefaultInitialize();

            //
            // Setup test data
            //
            ErrorResultTO errors      = new ErrorResultTO();
            Guid          callBackID  = Guid.NewGuid();
            string        serviceName = "wizardtest";

            IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList();

            string error;

            dataList.TryCreateScalarTemplate("", "testvalue", "", true, out error);
            dataList.TryCreateScalarValue("321", "testvalue", out error);

            DataListMergeOpsTO dataListMergeOpsTO = new DataListMergeOpsTO(dataList.UID);

            ServiceLocator serviceLocator = new ServiceLocator();

            ImportService.SatisfyImports(serviceLocator);

            //
            // Connect to the server
            //
            IEnvironmentConnection conn = new EnvironmentConnection();

            conn.Address = new Uri(ServerSettings.DsfAddress);
            conn.Connect();

            IEventAggregator          eventAggregator       = ImportService.GetExportValue <IEventAggregator>();
            IFrameworkSecurityContext securityContext       = ImportService.GetExportValue <IFrameworkSecurityContext>();
            IEnvironmentConnection    environmentConnection = ImportService.GetExportValue <IEnvironmentConnection>();

            IEnvironmentModel environment = new EnvironmentModel(eventAggregator, securityContext, environmentConnection);

            environment.EnvironmentConnection = conn;

            //
            // Write the datalist to the server over the datalist channel
            //
            conn.DataListChannel.WriteDataList(dataList.UID, dataList, errors);

            //
            // Add an execution callback, the action of this call back will set the reset event allowing the test to continue
            //
            conn.ExecutionChannel.AddExecutionStatusCallback(callBackID, new Action <ExecutionStatusCallbackMessage>(m =>
            {
                if (m.MessageType == ExecutionStatusCallbackMessageType.CompletedCallback)
                {
                    resetEvent.Set();
                }
            }));

            //
            // Get endpoint to query and make request to server
            //
            Uri enpoint = serviceLocator.GetEndpoint(WizardEndpointGenerationStrategyProvider.ServiceWithDataListMergeAndExecutionCallBackKey, new Tuple <string, IEnvironmentModel, DataListMergeOpsTO, Guid>(serviceName, environment, dataListMergeOpsTO, callBackID));

            WebRequest   wr      = WebRequest.Create(enpoint);
            WebResponse  wrsp    = wr.GetResponse();
            Stream       s       = wrsp.GetResponseStream();
            StreamReader sr      = new StreamReader(s);
            string       payload = sr.ReadToEnd();

            //
            // Wait for completed callback
            //
            resetEvent.Wait(10000);

            //
            // Get datalist from the server
            //
            IBinaryDataList resultDataList = conn.DataListChannel.ReadDatalist(dataList.UID, errors);

            //
            // Clean up
            //
            conn.Disconnect();

            IBinaryDataListEntry testValueEntry;

            resultDataList.TryGetEntry("testvalue", out testValueEntry, out error);

            IBinaryDataListEntry inValueEntry;

            resultDataList.TryGetEntry("invalue", out inValueEntry, out error);

            string expected = "123|321";
            string actual   = testValueEntry.FetchScalar().TheValue + "|" + inValueEntry.FetchScalar().TheValue;

            Assert.AreEqual(expected, actual);
        }