Пример #1
0
        public async Task SetupAsync()
        {
            _eventHandler        = A.Fake <IEventHandler <IWebRequest> >();
            _eventHandlerFactory = A.Fake <IEventHandlerFactory>();
            A.CallTo(() => _eventHandlerFactory.Create(A <IEnumerable <IEventHandlerSpecification <IWebRequest> > > ._)).Returns(_eventHandler);

            _predicate = A.Fake <Func <IWebRequestEvent, bool> >();
            var predicateSpec = A.Fake <IWebRequestPredicateSpecification>();

            A.CallTo(() => predicateSpec.Build()).Returns(_predicate);

            _responseFactory = A.Fake <Func <IWebResponse, Task> >();
            var responseSpec = A.Fake <IWebRequestResponseSpecification>();

            A.CallTo(() => responseSpec.BuildFactory()).Returns(_responseFactory);

            _handler     = A.Dummy <Func <IEventContext <IWebRequest>, CancellationToken, Task> >();
            _handlerSpec = A.Fake <IEventHandlerSpecification <IWebRequest> >();
            A.CallTo(() => _handlerSpec.Build()).Returns(_handler);

            _sut = new WebComponent();
            var configSpec = _sut.CreateConfigurationSpecification <WebComponentSpecification>(_eventHandlerFactory);

            configSpec.OnRequest(r =>
            {
                r.AddPredicateSpecification(predicateSpec);
                r.SetResponseSpecification(responseSpec);
                r.AddHandlerSpecification(_handlerSpec);
            });
            await configSpec.ApplyAsync();
        }
Пример #2
0
        public void EnterValueIntoField(string field)
        {
            var webComponent = new WebComponent(Driver);
            var input        = webComponent.FindFieldByLabel(field);

            input.Click();
        }
Пример #3
0
        public void CheckValueInField(string value, string field)
        {
            var webComponent  = new WebComponent(Driver);
            var fieldElement  = webComponent.FindFieldByLabel(field);
            var valueElements = fieldElement.FindDescendants(WebComponent.ByText(value));
            var valueElement  = valueElements.FirstOrDefault(el => el.Displayed && value.Equals(el.Text, StringComparison.CurrentCultureIgnoreCase));

            valueElement.Click();
        }
Пример #4
0
        public void UpdatePage(WebComponent source, WebSubmission values)
        {
            WebPage page = (WebPage)source;

            try {
                WebForm  proc_form  = (WebForm)page.Children.Where(o => o.ID.Equals("proc_form")).First();
                WebTable proc_table = (WebTable)proc_form.Children.Where(o => o.ID.Equals("processes")).First();
                proc_table.ClearRows();
                foreach (ProcObject proc in this._pm.Processes)
                {
                    WebComponent icon_img = null;
                    if (null == proc.JpegB64)
                    {
                        proc.JpegB64 = "";
                        try {
                            Bitmap pico = Icon.ExtractAssociatedIcon(proc.Filename).ToBitmap();
                            icon_img     = new WebImage(pico);
                            proc.JpegB64 = ((WebImage)icon_img).Src;
                        } catch (Exception) {
                            // XXX
                        }
                    }
                    else
                    {
                        icon_img = new WebImage(proc.JpegB64);
                    }

                    if (null != icon_img)
                    {
                        ((WebImage)icon_img).WidthPx  = 16;
                        ((WebImage)icon_img).HeightPx = 16;
                    }
                    else
                    {
                        icon_img = new WebText("");
                    }

                    proc_table.AddBodyRow(
                        "proc-row-" + proc.ProcId,
                        icon_img,
                        new WebText(proc.ProcName),
                        new WebText(proc.ProcId.ToString()),
                        new WebText(proc.ProcUser),
                        new WebText(proc.CPUPercent.ToString("n2")),
                        new WebText(WebComponent.FormatDataSize(proc.ReadBytesSec)),
                        new WebText(WebComponent.FormatDataSize(proc.WriteBytesSec)),
                        new WebText(WebComponent.FormatDataSize(proc.WorkingSet)),
                        new WebCheckbox("Kill", "proc_guid", proc.GUID.ToString())
                        );
                }
            } catch (InvalidOperationException ex) {
                Trace.TraceError(ex.Message);
            } catch (NullReferenceException ex) {
                Trace.TraceError(ex.Message);
            }
        }
Пример #5
0
        public async Task <bool> ReplaceData(string tenant, string environment,
                                             string entity,
                                             WebComponent data)
        {
            var patch = new JsonPatchDocument()
                        .Replace("/expression", data.Expression)
                        .Replace("/customElementName", data.CustomElement);

            var dataAsString = JsonConvert.SerializeObject(patch);

            var response = await _apiClient.Patch($"/api/v1/{tenant}/{environment}/model/webcomponent/{entity}",
                                                  new StringContent(dataAsString,
                                                                    Encoding.UTF8,
                                                                    "application/json")).ConfigureAwait(false);

            return(response.Success);
        }
Пример #6
0
 public void InitComponent(Transform componentRoot)
 {
     this.ComponentRoot    = componentRoot;
     DataNodeComponent     = FindAndRegisterComponent <DataNodeComponent>();
     DataTableComponent    = FindAndRegisterComponent <DataTableComponent>();
     DownloadComponent     = FindAndRegisterComponent <DownloadComponent>();
     FsmComponent          = FindAndRegisterComponent <FSMComponent>();
     ResourceComponent     = FindAndRegisterComponent <ResourceComponent>();
     SettingComponent      = FindAndRegisterComponent <SettingComponent>();
     SoundComponent        = FindAndRegisterComponent <SoundComponent>();
     TimerComponent        = FindAndRegisterComponent <TimerComponent>();
     WebComponent          = FindAndRegisterComponent <WebComponent>();
     UpdateComponent       = FindAndRegisterComponent <UpdateComponent>();
     LocalizationComponent = FindAndRegisterComponent <LocalizationComponent>();
     VideoComponent        = FindAndRegisterComponent <VideoComponent>();
     InputComponent        = FindAndRegisterComponent <InputComponent>();
     SceneComponent        = FindAndRegisterComponent <SceneComponent>();
 }
Пример #7
0
        public IComponent Apply(IHostBuilder hostBuilder)
        {
            var component = new WebComponent();

            hostBuilder.ConfigureWebHostDefaults(w =>
            {
                ConfigreBuilderAction?.Invoke(w);
                w.Configure(app =>
                {
                    app.Use(async(context, next) =>
                    {
                        await component.ProcessAsync(context);
                        await next();
                    });
                });
            });

            return(component);
        }
Пример #8
0
        internal static void CheckWebApplicationAvailability(WebComponent webComponent)
        {
            Logger.Instance.Log(LogLevel.Info, "Checking '{0}' web application availability", webComponent.Id);

            const string healthCheckPageContent = "I'm alright";
            const string healthCheckPageName    = "HealthCheck.aspx";
            string       healthCheckPagePath    = Path.Combine(webComponent.InstallationPath, healthCheckPageName);
            string       healthCheckPageUrl     = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", webComponent.Url, healthCheckPageName);

            try
            {
                webComponent.TargetFileSystem.WriteAllTextToFile(healthCheckPagePath, string.Format(CultureInfo.InvariantCulture, "<%= \"{0}\" %>", healthCheckPageContent));

                CheckUrlAvailability(healthCheckPageUrl);
            }
            finally
            {
                webComponent.TargetFileSystem.DeleteFile(healthCheckPagePath);
            }
        }
        public override void ApplyToWebComponent(WebComponent webComponent)
        {
            Logger.Instance.Log(LogLevel.Info, "\nDeploying component ({0}):\n", webComponent.Id);

            string pathToAppOfflineHtm = BaseFileSystem.CombinePaths(webComponent.InstallationPath, "app_offline.htm");

            if (string.IsNullOrEmpty(webComponent.ManagedRuntimeVersion))
            {
                using (FileStream appOfflineHtm = webComponent.TargetFileSystem.OpenFile(pathToAppOfflineHtm))
                {
                    StreamWriter appOfflineHtmWriter = new StreamWriter(appOfflineHtm);
                    appOfflineHtmWriter.WriteLine("This is temporary app_offline.htm generated by a deployment script to stop web application.");
                    appOfflineHtmWriter.WriteLine("If you see this - please remove the file");
                }
            }

            ApplyToCodeTreeComponent(webComponent);

            if (string.IsNullOrEmpty(webComponent.ManagedRuntimeVersion) && webComponent.TargetFileSystem.FileExists(pathToAppOfflineHtm))
            {
                webComponent.TargetFileSystem.DeleteFile(pathToAppOfflineHtm);
            }
        }
Пример #10
0
        public async Task ReplaceData_Successful()
        {
            var data = new WebComponent()
            {
                Expression    = @"// OMNIA Low-Code Development Platform
// Text Area Web Component

class TextareaElement extends HTMLElement {

    constructor() {
        super();

        this.textarea = document.createElement('textarea');
        this.textarea.setAttribute('class', 'form-control');

        this.textarea.onchange = this.valueUpdated.bind(this);
    }

    connectedCallback() {
        this.appendChild(this.textarea);
    }

    valueUpdated(event) {
        // When the onChange event is fired, dispatch a new event 'value-updated' to notify the OMNIA Platform that the values has been updated
        this.dispatchEvent(new CustomEvent('value-updated', {
            detail: {
                value: event.target.value
            }
        }));
    }

    set value(newValue) {
        this.textarea.value = newValue;
    }

    set isReadOnly(newValue) {
        this.textarea.disabled = (newValue === true);
    }

    set isPreviousValue(newValue) {
        this.textarea.style.textDecoration = newValue === true ? 'line-through' : null;
    }

    set valueHasChanged(newValue) {
        this.textarea.style.border = newValue === true ? '2px solid #ffe187' : null;
    }
}

customElements.define('omnia-textarea', TextareaElement);",
                CustomElement = "omnia-textarea"
            };

            var apiClientMock = new Mock <IApiClient>();

            apiClientMock.Setup(r => r.Patch(It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync((new ApiResponse(true)));

            var service = new WebComponentApplyService(apiClientMock.Object);

            await service.ReplaceData(Tenant, Environment, Entity, data)
            .ConfigureAwait(false);

            apiClientMock.Verify(r => r.Patch($"/api/v1/{Tenant}/{Environment}/model/webcomponent/{Entity}",
                                              It.IsAny <StringContent>()));
        }
Пример #11
0
        public void SubmitPage()
        {
            var webComponent = new WebComponent(Driver);

            webComponent.SubmitPage();
        }
Пример #12
0
        public void EnterValueIntoField(string value, string field)
        {
            var webComponent = new WebComponent(Driver);

            webComponent.SetFieldValue(field, value);
        }
Пример #13
0
 public override void ApplyToWebComponent(WebComponent webComponent)
 {
     throw new NotImplementedException();
 }
Пример #14
0
 public void VerifyComponentSameType()
 {
     Assert.False(WebComponent.VerifyType("x-com", typeof(MyComponent), out _));
 }
Пример #15
0
 public abstract void ApplyToWebComponent(WebComponent webComponent);
Пример #16
0
 private void OnKillButton(WebComponent source, WebSubmission values)
 {
     //Console.WriteLine( values.Headers.ToString() );
 }