Task SetupWindowForTests <THandler>(IWindow window, Func <Task> runTests, IMauiContext mauiContext = null) where THandler : class, IElementHandler { mauiContext ??= MauiContext; return(InvokeOnMainThreadAsync(async() => { var applicationContext = mauiContext.MakeApplicationScope(UI.Xaml.Application.Current); var appStub = new MauiAppNewWindowStub(window); UI.Xaml.Application.Current.SetApplicationHandler(appStub, applicationContext); WWindow newWindow = null; try { ApplicationExtensions.CreatePlatformWindow(UI.Xaml.Application.Current, appStub, new Handlers.OpenWindowRequest()); newWindow = window.Handler.PlatformView as WWindow; await runTests.Invoke(); } finally { window.Handler.DisconnectHandler(); await Task.Delay(10); newWindow?.Close(); appStub.Handler.DisconnectHandler(); } })); }
public void Finish(int id) { ApplicationExtensions.InvokeInUIThread(() => { widget.Visible = false; }); }
static bool IsOneNoteInstalled() { const string FriendlyAppName = "FriendlyAppName", SubKey = @"Applications\onenote.exe"; var isInstalled = false; var line = ONENOTE_APP_NOT_FOUND; using (var k = Registry.ClassesRoot.OpenSubKey(SubKey)) { if (k != null && k.GetValue(FriendlyAppName) != null) { var filePath = ApplicationExtensions.GetExeFilePath(); var exeFileInfo = new Utils.ExeFileInfo(filePath); #if DEBUG var nl = new[] { Environment.NewLine }; var options = StringSplitOptions.None; var args = exeFileInfo.ToString().Split(nl, options); foreach (var arg in args) { Tracer.WriteDebugLine(arg); } #endif line = string.Format("{0} ({1}) is installed", k.GetValue(FriendlyAppName), exeFileInfo.ImageType); isInstalled = exeFileInfo.Is32Bit(); } } Tracer.WriteTraceMethodLine(line); return(isInstalled); }
/// <summary> /// Draws the frame. /// </summary> /// <param name="frame">Frame represented as array of bytes. If this parameter is omitted previous frame is redrawn.</param> public void DrawFrame(byte[] frame = null) { if (!drawQueued) { lock (imgLock) { if (img == null) { return; } if (frame != null) { converter.Convert(frame, ref outBuffer); img.Copy(outBuffer); cursorDrawn = false; } if (!anythingDrawnAfterLastReconfiguration && frame != null) { anythingDrawnAfterLastReconfiguration = true; handler.Init(); } ApplicationExtensions.InvokeInUIThread(QueueDraw); drawQueued = true; } } }
protected override void OnAttach(VideoBackend backend) { var videoPeripheral = (AutoRepaintingVideo)backend.Video; element = videoPeripheral; lastRewrite = CustomDateTime.Now; EnsureAnalyserWidget(); videoPeripheral.ConfigurationChanged += (w, h, f, e) => ApplicationExtensions.InvokeInUIThread(() => displayWidget.SetDisplayParameters(w, h, f, e)); videoPeripheral.FrameRendered += (f) => ApplicationExtensions.InvokeInUIThread(() => displayWidget.DrawFrame(f)); displayWidget.InputAttached += i => { if (i is IKeyboard) { keyboardsComboBox.SelectedItem = i; } else if (i is IPointerInput) { pointersComboBox.SelectedItem = i; } }; if (backend.Frame != null) { // this must be called after setting `ConfigurationChanged` event; // otherwise the frame set here would be overrwritten by a new, empty, instance ApplicationExtensions.InvokeInUIThreadAndWait(() => { displayWidget.SetDisplayParameters(backend.Width, backend.Height, backend.Format, backend.Endianess); displayWidget.DrawFrame(backend.Frame); }); } }
public void WhenDeployingListOfFiles_ShouldCopyExistingFilesToRelativeSubFolder_Fact() { // Arrange var app = this._serverManager.Sites[0].Applications.Add(Helper.Randomize("/test"), @"c:\temp\target"); var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict); fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\temp\target")).Returns(false); fileSystem.Setup(f => f.DirectoryCreate(@"c:\temp\target")); fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\temp\target\relative")).Returns(false); fileSystem.Setup(f => f.DirectoryCreate(@"c:\temp\target\relative")); fileSystem.Setup <bool>(f => f.FileExists(@"c:\Temp\MySite\file1.html")).Returns(true); fileSystem.Setup <bool>(f => f.FileExists(@"c:\Temp\MySite\file2.html")).Returns(true); fileSystem.Setup <bool>(f => f.FileExists(@"c:\Temp\MySite\file3.html")).Returns(false); fileSystem.Setup(f => f.FileCopy(@"c:\Temp\MySite\file1.html", @"c:\temp\target\relative\file1.html", true)); fileSystem.Setup(f => f.FileCopy(@"c:\Temp\MySite\file2.html", @"c:\temp\target\relative\file2.html", true)); // Act ApplicationExtensions.Deploy(app, new string[] { @"c:\Temp\MySite\file1.html", @"c:\Temp\MySite\file2.html", @"c:\Temp\MySite\file3.html" }, @"relative", fileSystem.Object); // Assert fileSystem.VerifyAll(); }
public async Task <IActionResult> GetPenelo(string value, CancellationToken cancellationToken = new CancellationToken()) { var penelo = _httpContextAccessor.HttpContext.Request.Headers["Origin"]; if (penelo.ToString() == _configuration["Penelo"] || penelo.ToString() == "http://localhost:8080") { try { var key = _configuration["SimpleWebRTC:Key"]; var secret = _configuration["SimpleWebRTC:Secret"]; var x = await ApplicationExtensions.Get <Penelo>(key, secret); return(Ok(x)); } catch { return(BadRequest()); } } else { return(BadRequest(new { message = "Sorry, bro." })); } }
public void TestGetSystemLanguage() { foreach (var systemLanguage in Enum.GetValues(typeof(SystemLanguage))) { string systemLanguageString = ApplicationExtensions.GetStringValueOfSystemLanguage((SystemLanguage)systemLanguage); Assert.AreEqual(systemLanguage.ToString(), systemLanguageString); } }
public virtual async Task <IActionResult> Post([FromBody] T entity) { await this.Uow.RegisterNewAsync <T>(entity); await Uow.CommitAsync(); return(Created($"{HttpContext.Request.Path.ToUriComponent()}/{ApplicationExtensions.GetKeyValue(entity)}", ApplicationExtensions.GetKeyValue(entity))); }
public void Run() { ApplicationExtensions.InvokeInUIThread(() => { var window = new Window(); window.Width = 800; window.Height = 600; window.Content = new LogViewer(LuceneLoggerBackend.Instance); window.Show(); }); }
public async Task <IActionResult> UpdateLicenceEstablishment([FromBody] ViewModels.ApplicationLicenseSummary item, string licenceId) { if (item == null || string.IsNullOrEmpty(licenceId) || licenceId != item.LicenseId) { return(BadRequest()); } MicrosoftDynamicsCRMadoxioLicences licence = _dynamicsClient.GetLicenceByIdWithChildren(licenceId); if (licence == null) { return(NotFound()); } if (!CurrentUserHasAccessToLicenseOwnedBy(licence.AdoxioLicencee.Accountid)) { return(Forbid()); } MicrosoftDynamicsCRMadoxioLicences patchObject = new MicrosoftDynamicsCRMadoxioLicences() { AdoxioEstablishmentphone = item.EstablishmentPhoneNumber, AdoxioEstablishmentaddresscity = item.EstablishmentAddressCity, AdoxioEstablishmentaddressstreet = item.EstablishmentAddressStreet, AdoxioEstablishmentaddresspostalcode = item.EstablishmentAddressPostalCode }; try { await _dynamicsClient.Licenceses.UpdateAsync(licenceId, patchObject); } catch (HttpOperationException httpOperationException) { _logger.LogError(httpOperationException, "Error updating licence establishment"); throw new Exception("Unable to update licence establishment"); } try { licence = _dynamicsClient.GetLicenceByIdWithChildren(licenceId); } catch (HttpOperationException httpOperationException) { _logger.LogError(httpOperationException, "Error getting licence"); throw new Exception("Unable to get licence after update"); } IEnumerable <MicrosoftDynamicsCRMadoxioApplication> applicationsInProgress = _dynamicsClient.GetApplicationsForLicenceByApplicant(licence.AdoxioLicencee.Accountid); var applications = applicationsInProgress.Where(app => app._adoxioAssignedlicenceValue == licence.AdoxioLicencesid).ToList(); licence.AdoxioLicenceType = ApplicationExtensions.GetCachedLicenceType(licence._adoxioLicencetypeValue, _dynamicsClient, _cache); return(new JsonResult(licence.ToLicenseSummaryViewModel(applications))); }
public virtual async Task <IActionResult> Post([FromBody] T entity) { var validations = this.Domain.AddValidation(entity); if (validations.Count() == 0) { await this.Domain.AddAsync(entity); return(Created($"{HttpContext.Request.Path.ToUriComponent()}/{ApplicationExtensions.GetKeyValue(entity)}", ApplicationExtensions.GetKeyValue(entity))); } return(BadRequest(validations)); }
public static SAPbobsCOM.Company Conectar_Aplicacion() { CapaDatos.DConexion oConexion = new CapaDatos.DConexion(); oCompany = oConexion.oCompany; sCodUsuActual = oCompany.UserSignature.ToString(); sNomUsuActual = ApplicationExtensions.CurrentUserName(); sAliasUsuActual = oCompany.UserName; sCurrentCompanyDB = oCompany.CompanyDB; return(oCompany); }
public void WhenVirtualDirectoryPathExist_ShouldJustCopy() { // Arrange var mock = new WebServerMockGenerator() .MockApplication() .MockApplicationDeployVirtualDirectoryPathExistShouldJustCopy(); // Act, Assert ApplicationExtensions.Deploy( mock.ServerManager.Sites[0].Applications[mock.MockApplicationName], @"c:\Temp\MySite", mock.FileSystem.Object); }
private List <ApplicationLicenseSummary> GetLicensesByLicencee(string licenceeId) { var expand = new List <string> { "adoxio_adoxio_licences_adoxio_application_AssignedLicence", "adoxio_LicenceType", "adoxio_establishment" }; List <ApplicationLicenseSummary> licenseSummaryList = new List <ApplicationLicenseSummary>(); IEnumerable <MicrosoftDynamicsCRMadoxioLicences> licences = null; if (string.IsNullOrEmpty(licenceeId)) { licences = _dynamicsClient.Licenceses.Get(expand: expand).Value; } else { var filter = $"_adoxio_licencee_value eq {licenceeId}"; try { licences = _dynamicsClient.Licenceses.Get(filter: filter, expand: expand, orderby: new List <string> { "modifiedon desc" }).Value; licences = licences .Where(licence => { return(licence.Statuscode != (int)LicenceStatusCodes.Cancelled && licence.Statuscode != (int)LicenceStatusCodes.Inactive); }) .Select(licence => { licence.AdoxioLicenceType = ApplicationExtensions.GetCachedLicenceType(licence._adoxioLicencetypeValue, _dynamicsClient, _cache); return(licence); }); } catch (HttpOperationException) { licences = null; } } if (licences != null) { IEnumerable <MicrosoftDynamicsCRMadoxioApplication> applicationsInProgress = _dynamicsClient.GetApplicationsForLicenceByApplicant(licenceeId); foreach (var licence in licences) { var applications = applicationsInProgress.Where(app => app._adoxioAssignedlicenceValue == licence.AdoxioLicencesid).ToList(); licenseSummaryList.Add(licence.ToLicenseSummaryViewModel(applications)); } } return(licenseSummaryList); }
public void WhenSourceDoesNotExist_ShouldThrow() { // Arrange var mock = new WebServerMockGenerator() .MockApplicationDeploySourceDoesNotExist(); // Act, Assert var exception = Assert.Throws <Exception>(() => ApplicationExtensions.Deploy( mock.ServerManager.Sites[0].Applications[0], @"c:\Temp\MySite", mock.FileSystem.Object)); Assert.Equal(@"Failed to deploy files to application, source directory does not exist: 'c:\Temp\MySite'.", exception.Message); }
public void WhenVirtualDirectoryPathExist_IfRelativePathProvided_ShouldCopyToRelative() { // Arrange var mock = new WebServerMockGenerator() .MockApplication() .MockApplicationDeployVirtualDirectoryPathExistIfRelativePathProvidedShouldCopyToRelative(); // Act, Assert ApplicationExtensions.Deploy( mock.ServerManager.Sites[0].Applications[mock.MockApplicationName], @"c:\Temp\MySite", mock.FileSystem.Object, @"..\otherfolder"); }
public void WhenSourceDoesNotExist_ShouldThrow_Fact() { // Arrange var app = this._serverManager.Sites[0].Applications[0]; var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict); fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\Temp\MySite")).Returns(false); // Act, Assert var exception = Assert.Throws <Exception>(() => ApplicationExtensions.Deploy(app, @"c:\Temp\MySite", fileSystem.Object)); Xunit.Assert.Equal(@"Failed to deploy files to application, source directory does not exist: 'c:\Temp\MySite'.", exception.Message); fileSystem.VerifyAll(); }
public void WhenVirtualDirectoryDoesNotExist_ShouldThrow() { // Arrange var mock = new WebServerMockGenerator() .MockApplication() .MockApplicationVirtualDirectoryDoesNotExist(); // Act, Assert var exception = Assert.Throws <Exception>(() => ApplicationExtensions.Deploy( mock.ServerManager.Sites[0].Applications[mock.MockApplicationName], @"c:\Temp\MySite", mock.FileSystem.Object)); Assert.Equal(string.Format(@"Application '{0}' does not have a virtual directory.", mock.MockApplicationName), exception.Message); }
public void WhenDeployingFileContent_ShouldCreateFile() { // Arrange var mock = new WebServerMockGenerator() .MockApplication() .MockApplicationDeployFileContentShouldCreateFile(); // Act, Assert ApplicationExtensions.Deploy( mock.ServerManager.Sites[0].Applications[mock.MockApplicationName], mock.MockRelativePath, mock.MockSampleFileContent, mock.FileSystem.Object); }
public void WhenDeployingListOfFiles_IfListIsEmpty_ShouldThrow_Fact() { // Arrange var app = this._serverManager.Sites[0].Applications.Add(Helper.Randomize("/test"), @"c:\temp\target"); var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict); fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\Temp\MySite")).Returns(true); fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\temp\target")).Returns(true); fileSystem.Setup(f => f.DirectoryCopy(@"c:\Temp\MySite", @"c:\temp\target")); // Act, Assert var exception = Assert.Throws <ArgumentNullException>(() => ApplicationExtensions.Deploy(app, (string[])null, "", fileSystem.Object)); Xunit.Assert.True(exception.Message.Contains("filePaths")); }
public void WhenDeployingListOfFiles_IfListIsEmpty_ShouldThrow() { // Arrange var mock = new WebServerMockGenerator() .MockApplication() .MockApplicationDeployListOfFilesIfListIsEmptyShouldThrow(); // Act, Assert var exception = Assert.Throws <ArgumentNullException>(() => ApplicationExtensions.Deploy( mock.ServerManager.Sites[0].Applications[mock.MockApplicationName], (string[])null, "", mock.FileSystem.Object)); Assert.True(exception.Message.Contains("filePaths")); }
public override bool Execute(out string message) { bool result = false; try { string resultMessage = ApplicationExtensions.Install(this.ServerName, this.PackageLocation, this.TargetDir); message = resultMessage; result = !resultMessage.Contains("error"); } catch (Exception exe) { message = exe.Message; } return(result); }
public override bool Execute(out string message) { bool result = false; try { string UninstallGuid = RegistryHelper.GetUninstallGuid(this.ApplicationInfo.ApplicationName, this.ServerName); string resultMessage = ApplicationExtensions.Uninstall(this.ServerName, this.ApplicationInfo.ApplicationName, UninstallGuid, RegistryHelper.GetVersion(UninstallGuid, this.ServerName)); message = resultMessage; result = !resultMessage.Contains("error"); } catch (Exception exe) { message = exe.Message; } return(result); }
public void WhenVirtualDirectoryPathExist_ShouldJustCopy_Fact() { // Arrange var app = this._serverManager.Sites[0].Applications.Add(Helper.Randomize("/test"), @"c:\temp\target"); var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict); fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\Temp\MySite")).Returns(true); fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\temp\target")).Returns(true); fileSystem.Setup(f => f.DirectoryCopy(@"c:\Temp\MySite", @"c:\temp\target")); // Act ApplicationExtensions.Deploy(app, @"c:\Temp\MySite", fileSystem.Object); // Assert fileSystem.VerifyAll(); }
public void DrawFrame(byte[] frame) { if (!drawQueued) { lock (imgLock) { if (img == null) { return; } converter.Convert(frame, ref outBuffer); img.Copy(outBuffer); ApplicationExtensions.InvokeInUIThread(QueueDraw); drawQueued = true; } } }
public void WhenVirtualDirectoryDoesNotExist_ShouldThrow_Fact() { // Arrange var appName = Helper.Randomize("/test"); var app = this._serverManager.Sites[0].Applications.Add(appName, ""); app.VirtualDirectories.Clear(); var fileSystem = new Mock <FileSystemBase>(MockBehavior.Strict); fileSystem.Setup <bool>(f => f.DirectoryExists(@"c:\Temp\MySite")).Returns(true); // Act, Assert var exception = Assert.Throws <Exception>(() => ApplicationExtensions.Deploy(app, @"c:\Temp\MySite", fileSystem.Object)); Xunit.Assert.Equal(string.Format(@"Application '{0}' does not have a virtual directory.", appName), exception.Message); fileSystem.VerifyAll(); }
public void WhenDeployingListOfFiles_ShouldCopyExistingFilesToRelativeSubFolder() { // Arrange var mock = new WebServerMockGenerator() .MockApplication() .MockApplicationDeployListOfFilesShouldCopyExistingFilesToRelativeSubFolder(); // Act, Assert ApplicationExtensions.Deploy( mock.ServerManager.Sites[0].Applications[mock.MockApplicationName], new [] { @"c:\Temp\MySite\file1.html", @"c:\Temp\MySite\file2.html", @"c:\Temp\MySite\file3.html" }, @"relative", mock.FileSystem.Object); }
public EditApplicationModelValidator() { RuleFor(m => m.ApplicationId).NotEmpty(); RuleFor(m => m.ApplicationName).NotEmpty(); RuleFor(m => m.ApplicationName) .Must(name => !ApplicationExtensions.IsSystemReservedApplicationName(name)) .WithMessage(p => $"'{ p.ApplicationName}' is a reserved name and may not be used. Please choose another name."); RuleFor(m => m.ClaimSetName) .NotEmpty() .WithMessage("You must choose a Claim Set"); RuleFor(m => m.EducationOrganizationIds) .NotEmpty() .WithMessage("You must choose at least one Education Organization"); RuleFor(m => m.Environment).NotNull(); RuleFor(m => m.VendorId).NotEmpty(); }
public void Update(int id, string description, int?progress) { ApplicationExtensions.InvokeInUIThread(() => { widget.Visible = true; widget.text.Text = description; widget.text.Visible = !string.IsNullOrEmpty(description); if (progress.HasValue) { widget.progressBar.Indeterminate = false; widget.progressBar.Fraction = progress.Value / 100.0; } else { widget.progressBar.Indeterminate = true; } }); }