Exemple #1
0
 internal Element(BaseStorage storage, Guid obj, ApplicationType appType, int identifier)
 {
     _storage = storage;
     _obj = obj;
     _appType = appType;
     _identifier = identifier;
 }
        public SemanticValidator(FileFormatVersions format, ApplicationType app)
        {
            FileFormat = format;
            AppType = app;

            _curReg = new SemanticConstraintRegistry(format, app);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public SemanticConstraintRegistry(FileFormatVersions format, ApplicationType appType)
        {
            _format = format;
            _appType = appType;

            Initialize();
        }
 public OfficeApplicationObjectProvider(object officeApplicationObject, ApplicationType applicationType)
 {
     // TODO: Complete member initialization
     this.officeApplicationObject = officeApplicationObject;
     m_bExternalApplication = officeApplicationObject != null;
     this.applicationType = applicationType;
 }
        /// <summary>
        /// Register a constraint to this registry.
        /// </summary>
        public void RegisterConstraint(int elementTypeID, int ancestorTypeID, FileFormatVersions fileFormat, ApplicationType appType, SemanticConstraint constraint )
        {
            if ((fileFormat & _format) == _format && (appType & _appType) == _appType)
            {

                AddConstraintToDic(constraint, ancestorTypeID, _cleanList);
                AddConstraintToDic(constraint, elementTypeID, _semConstraintMap);
            }
        }
        internal static MonoProcess Start(ApplicationType type, string _targetExe)
        {
            if (type == ApplicationType.Desktopapplication)
                return new MonoDesktopProcess(_targetExe);
            if (type == ApplicationType.Webapplication)
                return new MonoWebProcess();

            throw new Exception("Unknown ApplicationType");
        }
        public async Task HelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ServerType delegateServer, ApplicationType applicationType)
        {
            var logger = new LoggerFactory()
                            .AddConsole()
                            .AddDebug()
                            .CreateLogger($"HelloWorld:{serverType}:{runtimeFlavor}:{architecture}:{delegateServer}");

            using (logger.BeginScope("HelloWorldTest"))
            {
                var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(applicationType), serverType, runtimeFlavor, architecture)
                {
                    ApplicationBaseUriHint = applicationBaseUrl,
                    EnvironmentName = "HelloWorld", // Will pick the Start class named 'StartupHelloWorld',
                    ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null,
                    SiteName = "HttpTestSite", // This is configured in the Http.config
                    TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0",
                    ApplicationType = applicationType
                };

                using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, logger))
                {
                    var deploymentResult = deployer.Deploy();
                    var httpClientHandler = new HttpClientHandler();
                    var httpClient = new HttpClient(httpClientHandler)
                    {
                        BaseAddress = new Uri(deploymentResult.ApplicationBaseUri),
                        Timeout = TimeSpan.FromSeconds(5),
                    };

                    // Request to base address and check if various parts of the body are rendered & measure the cold startup time.
                    var response = await RetryHelper.RetryRequest(() =>
                    {
                        return httpClient.GetAsync(string.Empty);
                    }, logger, deploymentResult.HostShutdownToken, retryCount: 30);

                    var responseText = await response.Content.ReadAsStringAsync();
                    try
                    {
                        Assert.Equal("Hello World", responseText);

                        response = await httpClient.GetAsync("/Path%3F%3F?query");
                        responseText = await response.Content.ReadAsStringAsync();
                        Assert.Equal("/Path??", responseText);

                        response = await httpClient.GetAsync("/Query%3FPath?query?");
                        responseText = await response.Content.ReadAsStringAsync();
                        Assert.Equal("?query?", responseText);
                    }
                    catch (XunitException)
                    {
                        logger.LogWarning(response.ToString());
                        logger.LogWarning(responseText);
                        throw;
                    }
                }
            }
        }
Exemple #8
0
        public void Save(ApplicationType type)
        {
            if (type == ApplicationType.Application && MainFunc != null)
            {
                MethodInfo wrappedMain = WrapMain(MainFunc);
                _assemblyBuilder.SetEntryPoint(wrappedMain, PEFileKinds.ConsoleApplication);
            }

            SaveAssembly(_fileName, _assemblyBuilder);
        }
 public static INodeCartridge GetHandler(ApplicationType applicationType)
 {
     switch (applicationType)
     {
         case ApplicationType.Mono:
             return new MonoCartridge();
         default:
             throw new MonoscapeException("Unknown application type found");
     }
 }
		/// <summary>
		/// Get the directory for the default location of the CruiseControl.NET data files.
		/// </summary>
		/// <param name="application">Type of the application. E.g. Server or WebDashboard.</param>
		/// <returns>The location of the CruiseControl.NET data files.</returns>
		public string GetDefaultProgramDataFolder(ApplicationType application)
		{
            if (application == ApplicationType.Unknown)
            {
                throw new ArgumentOutOfRangeException("application");
            }

            var pgfPath = AppDomain.CurrentDomain.BaseDirectory;
            return pgfPath;
		}
Exemple #11
0
 public async Task NonWindowsOS(
     ServerType serverType,
     RuntimeFlavor runtimeFlavor,
     RuntimeArchitecture architecture,
     ApplicationType applicationType,
     string applicationBaseUrl)
 {
     var smokeTestRunner = new SmokeTests(_logger);
     await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl);
 }
Exemple #12
0
 public Application(ApplicationType type, string applicant, string destacc, string destname, string memo)
 {
     AppType = type;
     Applicant = applicant;
     DestAcc = destacc;
     DestName = destname;
     Memo = memo;
     CreationTime = DateTime.Now;
     AppType = ApplicationType.APerson;
 }
        public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl)
        {
            using (_logger.BeginScope("NtlmAuthenticationTest"))
            {
                var musicStoreDbName = DbUtils.GetUniqueName();

                var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
                {
                    PublishApplicationBeforeDeployment = true,
                    TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0",
                    ApplicationType = applicationType,
                    ApplicationBaseUriHint = applicationBaseUrl,
                    EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
                    ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("NtlmAuthentation.config") : null,
                    SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config
                    UserAdditionalCleanup = parameters =>
                    {
                        DbUtils.DropDatabase(musicStoreDbName, _logger);
                    }
                };

                // Override the connection strings using environment based configuration
                deploymentParameters.EnvironmentVariables
                    .Add(new KeyValuePair<string, string>(
                        MusicStore.StoreConfig.ConnectionStringKey,
                        DbUtils.CreateConnectionString(musicStoreDbName)));

                using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger))
                {
                    var deploymentResult = deployer.Deploy();
                    var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
                    var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };

                    // Request to base address and check if various parts of the body are rendered & measure the cold startup time.
                    var response = await RetryHelper.RetryRequest(async () =>
                    {
                        return await httpClient.GetAsync(string.Empty);
                    }, logger: _logger, cancellationToken: deploymentResult.HostShutdownToken);

                    Assert.False(response == null, "Response object is null because the client could not " +
                        "connect to the server after multiple retries");

                    var validator = new Validator(httpClient, httpClientHandler, _logger, deploymentResult);

                    Console.WriteLine("Verifying home page");
                    await validator.VerifyNtlmHomePage(response);

                    Console.WriteLine("Verifying access to store with permissions");
                    await validator.AccessStoreWithPermissions();

                    _logger.LogInformation("Variation completed successfully.");
                }
            }
        }
        /// <summary>
        /// Function to save work detail.
        /// </summary>
        /// <param name="workDetail">work detail information</param>
        /// <param name="applicationType">Application type</param>
        public void InsertOrUpdate(WorkDetail workDetail, ApplicationType applicationType)
        {
            if (workDetail == null)
            {
                throw new ArgumentNullException(WorkDetailConst);
            }

            workDetail.Date = workDetail.Date.Date;
            workDetail.ApplicationID = (byte)applicationType;
            this.timesheetRepository.InsertOrUpdate(workDetail);
            this.unitOfWork.Save();
        }
 public async Task NonWindowsOS(
     ServerType serverType,
     RuntimeFlavor runtimeFlavor,
     RuntimeArchitecture architecture,
     ApplicationType applicationType,
     string applicationBaseUrl,
     bool noSource)
 {
     var testRunner = new PublishAndRunTests(_logger);
     await testRunner.Publish_And_Run_Tests(
         serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl, noSource);
 }
 public static LogServerComponent CreateLogServerComponent(ApplicationType appType,
                                                           LogServerComponentType logServer)
 {
     var ht = GetHost(appType, logServer.hostID);
     var component = new LogServerComponent(logServer.componentID, appType.applicationID, ht)
         {
             WorkingDir = logServer.workingDir,
             Port = logServer.port,
             HostName = ht.hostname
         };
     return component;
 }
        /// <summary>
        /// Inserts the specified work detail.
        /// </summary>
        /// <param name="workDetail">The work detail.</param>
        /// <param name="applicationType">Type of the application.</param>
        /// <returns>The total timesheet hours</returns>
        public decimal Insert(WorkDetail workDetail, ApplicationType applicationType)
        {
            if (workDetail == null)
            {
                throw new ArgumentNullException(WorkDetailConst);
            }

            workDetail.Date = workDetail.Date.Date;
            workDetail.ApplicationID = (byte)applicationType;
            var result = this.timesheetRepository.Insert(workDetail);
            this.unitOfWork.Save();

            return result;
        }
 public static ForgeComponent CreateForgeComponent(ApplicationType appType, ForgeComponentType forge)
 {
     var ht = GetHost(appType, forge.hostID);
     var component = new ForgeComponent(forge.componentID, appType.applicationID, ht)
         {
             OutputDirectory = ResolveRelativePath(forge.workingDir, forge.outputDir),
             InputDirectory = ResolveRelativePath(forge.workingDir, forge.inputDir),
             LogDir = ResolveRelativePath(forge.workingDir, Path.GetDirectoryName(forge.logFile)),
             WorkingDir = forge.workingDir,
             DataPrefix = forge.outputPrefixName
         };
     LoadCustomProperties(component, forge);
     return component;
 }
Exemple #19
0
 public static int GeneratePairedKey(string initialKey, ApplicationType appType)
 {
     string constantKey = "CashRegister2013";
     if (appType == ApplicationType.TaxCalculator)
     {
         constantKey = "TaxCalculator2014";
     }
     int hash = 23;
     hash = hash * 2 + initialKey.GetHashCode();
     hash = hash * 3 + constantKey.GetHashCode();
     hash = Math.Abs(hash);
     Debug.WriteLine("generated paired key: " + hash);
     return hash;
 }
 public static DgidxComponent CreateDgidxComponent(ApplicationType appType, DgidxComponentType dgidx)
 {
     var ht = GetHost(appType, dgidx.hostID);
     var component = new DgidxComponent(dgidx.componentID, appType.applicationID, ht)
         {
             WorkingDir = dgidx.workingDir,
             OutputDirectory = ResolveRelativePath(dgidx.workingDir,
                                                   RemovePrefixNameFromDir(dgidx.outputPrefix)),
             InputDirectory = ResolveRelativePath(dgidx.workingDir, RemovePrefixNameFromDir(dgidx.inputPrefix)),
             LogDir = ResolveRelativePath(dgidx.workingDir, Path.GetDirectoryName(dgidx.logFile)),
             DataPrefix = GetDataPrefixFromDir(dgidx.outputPrefix)
         };
     LoadCustomProperties(component, dgidx);
     return component;
 }
        public IosPushMessageSender(ApplicationType? appType)
        {
            if(appType == ApplicationType.Tablet)
                config = new ApnsConfiguration(PushSharp.Apple.ApnsConfiguration.ApnsServerEnvironment.Production,
                    Options.ApnsCertificateFileTablet, Options.ApnsCertificatePasswordTablet);
            else
                config = new ApnsConfiguration(PushSharp.Apple.ApnsConfiguration.ApnsServerEnvironment.Production,
                    Options.ApnsCertificateFileMobile, Options.ApnsCertificatePasswordMobile);

            SetUpFeedbackServiceTimer(Options.APNSFeedbackServiceRunDelay);

            apnsBroker = new ApnsServiceBroker(config);

            apnsBroker.OnNotificationFailed += (notification, aggregateEx) =>
            {
                aggregateEx.Handle(ex =>
                {
                    if (ex is ApnsNotificationException)
                    {
                        var notificationException = (ApnsNotificationException)ex;

                        var apnsNotification = notificationException.Notification;
                        var statusCode = notificationException.ErrorStatusCode;

                        logger.Error(string.Format("Apple Notification Failed: ID={0}, Code={1}, Token ={2}", apnsNotification.Identifier, statusCode, notification.DeviceToken));
                        System.Diagnostics.Debug.WriteLine(string.Format("Apple Notification Failed: ID={0}, Code={1}, Token ={2}", apnsNotification.Identifier, statusCode, notification.DeviceToken));
                    }
                    else
                    {
                        logger.Error(string.Format("Apple Notification Failed for some unknown reason : {0}, Token = {1}", ex.InnerException, notification.DeviceToken));
                        System.Diagnostics.Debug.WriteLine(string.Format("Apple Notification Failed for some unknown reason : {0}, Token = {1}", ex.InnerException, notification.DeviceToken));
                    }

                    notificationService.Unsubscribe(notification.DeviceToken, userId);

                    return true;
                });
            };

            apnsBroker.OnNotificationSucceeded += (notification) =>
            {
                logger.Info("Notification Successfully Sent to: " + notification.DeviceToken);
                System.Diagnostics.Debug.WriteLine("Notification Successfully Sent to: " + notification.DeviceToken);
            };

            apnsBroker.Start();
        }
        /// <summary>
        /// Sends push message to subscribed user device
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="deviceType"></param>
        /// <param name="token"></param>
        /// <param name="message"></param>
        public void Send(Int64 userId, DeviceType deviceType, string token, string message, ApplicationType? appType)
        {
            try
            {
                PushMessageSender pushMessageSender = GetPushMessageSender(deviceType, appType);

                if (pushMessageSender == null)
                {
                    throw new ApplicationException(string.Format("Device type: {0} is not supported", deviceType));
                }

                pushMessageSender.SendPushNotification(token, message, userId);
            }
            catch(Exception e)
            {
                throw new ApplicationException(e.Message);
            }
        }
Exemple #23
0
        public ClientInfo(Guid clientID)
        {
            ClientID = clientID;
            ClientType = Common.GetApplicationType();
            
            UserName = Thread.CurrentPrincipal.Identity.Name;

            if (string.IsNullOrEmpty(UserName))
                UserName = Environment.UserDomainName + "\\" + Environment.UserName;

            MachineName = Environment.MachineName;

            if (ClientType == ApplicationType.WindowsCui || ClientType == ApplicationType.WindowsGui)
            {
                ClientName = AppDomain.CurrentDomain.FriendlyName;
            }
            else if (ClientType == ApplicationType.Web)
            {
                ClientName = System.Web.HttpContext.Current.Request.ApplicationPath;
            }
        }
        public static DgraphComponent CreateDgraphComponent(ApplicationType appType, DgraphComponentType dgraph)
        {
            var ht = GetHost(appType, dgraph.hostID);
            var component = new DgraphComponent(dgraph.componentID, appType.applicationID, ht)
                {
                    WorkingDir = dgraph.workingDir,
                    LogDir = ResolveRelativePath(dgraph.workingDir, Path.GetDirectoryName(dgraph.logFile)),
                    InputDirectory = ResolveRelativePath(dgraph.workingDir,
                                                         RemovePrefixNameFromDir(dgraph.inputPrefix)),
                    UpdateDir = ResolveRelativePath(dgraph.workingDir, dgraph.updateDir),
                    UpdateLogDir = ResolveRelativePath(dgraph.workingDir, Path.GetDirectoryName(dgraph.updateLogFile))
                };
            LoadCustomProperties(component, dgraph);
            component.IndexDistributionDir = ResolveRelativePath(dgraph.workingDir,
                                                                 component.CustomProps["localIndexDir"]);
            component.DataPrefix = GetDataPrefixFromDir(dgraph.inputPrefix);
            component.Port = dgraph.port;
            component.HostName = ht.hostname;

            return component;
        }
Exemple #25
0
        /// <summary>
        /// 入口程序
        /// </summary>
        /// <param name="application"></param>
        public void Init(HttpApplication application)
        {
            if (null != application)
            {

                //关联处理事件
                application.BeginRequest += new EventHandler(Application_BeginRequest);
                application.AuthorizeRequest += new EventHandler(Application_AuthorizeRequest);

                applicationInstalled = ConfigurationManager.AppSettings["Installer"] == null;

                currentApplicationType = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;

                //检查是否安装
                CheckInstall(application.Context);

                if (currentApplicationType != ApplicationType.Installer)
                {
                    //启动工作线程
                    Hidistro.Core.Jobs.Jobs.Instance().Start();
                    ExtensionContainer.LoadExtensions();
                }
            }
        }
Exemple #26
0
 public static string GetApplicationPath(ApplicationType applicationType)
 {
     return(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "samples", applicationType == ApplicationType.Standalone ? "MusicStore.Standalone" : "MusicStore")));
 }
        public void TestReadScopeResourcesWithRegistedFullScope(Enums.ResourceType resourceType, ApplicationType appType)
        {
            InitFullScopeAdapter(appType);
            Dictionary <string, object> urlParameter = new Dictionary <string, object>()
            {
                { Partition, appInfo.Company.Partition }
            };

            ReadAndVerifyData(resourceType.ToString(), urlParameter);
        }
Exemple #28
0
        private async Task HelloWorld(RuntimeFlavor runtimeFlavor, ApplicationType applicationType, ANCMVersion ancmVersion)
        {
            var serverType   = ServerType.IISExpress;
            var architecture = RuntimeArchitecture.x64;
            var testName     = $"HelloWorld_{runtimeFlavor}";

            using (StartLog(out var loggerFactory, testName))
            {
                var logger = loggerFactory.CreateLogger("HelloWorldTest");

                var deploymentParameters = new DeploymentParameters(Helpers.GetOutOfProcessTestSitesPath(), serverType, runtimeFlavor, architecture)
                {
                    EnvironmentName             = "HelloWorld", // Will pick the Start class named 'StartupHelloWorld',
                    ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("AppHostConfig/Http.config") : null,
                    SiteName        = "HttpTestSite",           // This is configured in the Http.config
                    TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.1",
                    ApplicationType = applicationType,
                    ANCMVersion     = ancmVersion
                };

                using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
                {
                    var deploymentResult = await deployer.DeployAsync();

                    // Request to base address and check if various parts of the body are rendered & measure the cold startup time.
                    var response = await RetryHelper.RetryRequest(() =>
                    {
                        return(deploymentResult.HttpClient.GetAsync(string.Empty));
                    }, logger, deploymentResult.HostShutdownToken, retryCount : 30);

                    var responseText = await response.Content.ReadAsStringAsync();

                    try
                    {
                        Assert.Equal("Hello World", responseText);

                        response = await deploymentResult.HttpClient.GetAsync("/Path%3F%3F?query");

                        responseText = await response.Content.ReadAsStringAsync();

                        Assert.Equal("/Path??", responseText);

                        response = await deploymentResult.HttpClient.GetAsync("/Query%3FPath?query?");

                        responseText = await response.Content.ReadAsStringAsync();

                        Assert.Equal("?query?", responseText);

                        response = await deploymentResult.HttpClient.GetAsync("/BodyLimit");

                        responseText = await response.Content.ReadAsStringAsync();

                        Assert.Equal("null", responseText);

                        response = await deploymentResult.HttpClient.GetAsync("/Auth");

                        responseText = await response.Content.ReadAsStringAsync();

                        // We adapted the Http.config file to be used for inprocess too. We specify WindowsAuth is enabled
                        // We now expect that windows auth is enabled rather than disabled.
                        Assert.True("backcompat;Windows".Equals(responseText) || "latest;Windows".Equals(responseText), "Auth");
                    }
                    catch (XunitException)
                    {
                        logger.LogWarning(response.ToString());
                        logger.LogWarning(responseText);
                        throw;
                    }
                }
            }
        }
 /// <summary>
 /// Loads and validates the application configuration from a configuration section.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="applicationType">Type of the application.</param>
 /// <param name="systemType">Type of the system.</param>
 /// <returns>Application configuration</returns>
 public static Task <ApplicationConfiguration> Load(FileInfo file, ApplicationType applicationType, Type systemType) =>
 ApplicationConfiguration.Load(file, applicationType, systemType, true);
 private void setApplicationType(SchemaItemDTO dto, ApplicationType newApplicationType)
 {
     OnEvent(() => _presenter.SetApplicationType(dto, newApplicationType));
 }
Exemple #31
0
        /// <summary>
        /// Create a 106 kbps card type B like a credit card
        /// </summary>
        /// <param name="atqb">Data to decode</param>
        public Data106kbpsTypeB(byte[] atqb)
        {
            try
            {
                Command = atqb[0];
                NfcId   = new byte[4];
                atqb.AsSpan().Slice(1, 4).CopyTo(NfcId);
                ApplicationData = new byte[4];
                atqb.AsSpan().Slice(5, 4).CopyTo(ApplicationData);
                BitRates             = atqb[9];
                MaxFrameSize         = (MaxFrameSize)(atqb[10] & 0b1111_0000);
                ISO14443_4Compliance = (atqb[10] & 0b0000_11111) == 1;

                var fwi = atqb[11] & 0b1111_0000;
                if (fwi == 0b0000_0000)
                {
                    FrameWaitingTime = 302.1f;
                }
                else if (fwi == 0b0001_0000)
                {
                    FrameWaitingTime = 604.1f;
                }
                else if (fwi == 0b0010_0000)
                {
                    FrameWaitingTime = 1203.3f;
                }
                else if (fwi == 0b0011_0000)
                {
                    FrameWaitingTime = 2416.5f;
                }
                else if (fwi == 0b0100_0000)
                {
                    FrameWaitingTime = 4833.0f;
                }
                else if (fwi == 0b0101_0000)
                {
                    FrameWaitingTime = 9666.1f;
                }
                else if (fwi == 0b0110_0000)
                {
                    FrameWaitingTime = 19332.2f;
                }
                else if (fwi == 0b0111_0000)
                {
                    FrameWaitingTime = 38664.3f;
                }
                else if (fwi == 0b1000_0000)
                {
                    FrameWaitingTime = 77328.6f;
                }
                else if (fwi == 0b1001_0000)
                {
                    FrameWaitingTime = 154657.2f;
                }
                else if (fwi == 0b1010_0000)
                {
                    FrameWaitingTime = 309314.5f;
                }
                else if (fwi == 0b1011_0000)
                {
                    FrameWaitingTime = 618628.9f;
                }
                else if (fwi == 0b1100_0000)
                {
                    FrameWaitingTime = 1237257.8f;
                }
                else if (fwi == 0b1101_0000)
                {
                    FrameWaitingTime = 2474515.6f;
                }
                else if (fwi == 0b1110_0000)
                {
                    FrameWaitingTime = 4949031.3f;
                }

                NadSupported = (atqb[11] & 0b0000_0010) == 0b0000_0010;
                CidSupported = (atqb[11] & 0b0000_0001) == 0b0000_0001;

                ApplicationType = (ApplicationType)(atqb[11] & 0b0000_1100);
                // Ignore the 2 last bytes. They are CRC
            }
            catch (ArgumentOutOfRangeException ex)
            {
                throw new ArgumentOutOfRangeException($"Can't create a 106 kbpd card type B", ex.InnerException);
            }
        }
Exemple #32
0
        public void TestInvalidCodeDirectScopeIsIgnored(string scope, ApplicationType appType)
        {
            InitApiHelpers(appType);

            VerifyCodeDirectScope(scope, appType);
        }
Exemple #33
0
 private static string pkParameterNameForCmaxRatio(ApplicationType applicationType)
 {
     return(applicationType == ApplicationType.Multiple ? Constants.PKParameters.C_max_tLast_tEnd : Constants.PKParameters.C_max);
 }
Exemple #34
0
 public ContactHandler(string appId, string appSecret, ApplicationType appType, string language, IConfigurationProvider configManager)
     : base(appId, appSecret, appType, language, configManager)
 {
 }
Exemple #35
0
        public void TestOauthWithoutScopeRegister(string scope, string type, object errorCode, ApplicationType appType)
        {
            InitApiHelpers(appType);

            using (var appInfoRead = AuthenticationInfoProvider.Current.Manager.GetApplication(
                       new ApplicationSpecBuilder().ParameterEquals("type", appType.ToString()).ParameterContains("categories", "read_scope")))
            {
                using (var appInfoWrite = AuthenticationInfoProvider.Current.Manager.GetApplication(
                           new ApplicationSpecBuilder().ParameterEquals("type", appType.ToString()).ParameterContains("categories", "write_scope")))
                {
                    Dictionary <string, object> oauthParams = new Dictionary <string, object>()
                    {
                    };
                    oauthParams.Add("response_type", "code_direct");
                    oauthParams.Add("scope", scope);

                    string appId = string.Empty;
                    switch (type)
                    {
                    case "read":
                        appId = appInfoWrite.Key;
                        break;

                    case "write":
                        appId = appInfoRead.Key;
                        break;
                    }
                    oauthParams.Add("app_id", appId);

                    Handler handler = oAuthAPI.Read(oauthParams);
                    Assert.That(handler.HttpCode, Is.EqualTo(System.Net.HttpStatusCode.OK), "The http code is invalid");

                    APITestFramework.Resources.PublicAPI.Authentication result = XmlHelper.ParseXMLString <APITestFramework.Resources.PublicAPI.Authentication>(handler.RawContent);
                    Assert.That(result, Is.Not.Null, "Failed to parse the server's response");
                    Assert.That(int.Parse(result.Error), Is.EqualTo(errorCode), result.Message);
                }
            }
        }
Exemple #36
0
 /// <summary>
 /// Raises all BeforeSection events. These events are raised before a section is commited to the datastore
 /// </summary>
 public static void BeforeSection(Section section, ObjectState state, ApplicationType appType)
 {
     CSApplication.Instance().ExecutePreSectionUpdate(section,state,appType);
 }
Exemple #37
0
 /// <summary>
 /// Raises all BeforeGroup events. These events are raised before a group change is commited to the datastore
 /// </summary>
 public static void BeforeGroup(Group group, ObjectState state, ApplicationType appType)
 {
     CSApplication.Instance().ExecutePreSectionGroupUpdate(group,state,appType);
 }
 private void InitFullScopeAdapter(ApplicationType appType)
 {
     appInfo = GetDefaultApplication(appType);
     adapter = GetDefaultAdapter(appType);
 }
Exemple #39
0
        private static string IdentifierToName(ApplicationType appType, int identifier)
        {
            ElementClass idClass = GetClass(identifier);

            if (idClass == ElementClass.Library)
            {
                switch (identifier)
                {
                case 0x11000001: return("device");

                case 0x12000002: return("path");

                case 0x12000004: return("description");

                case 0x12000005: return("locale");

                case 0x14000006: return("inherit");

                case 0x15000007: return("truncatememory");

                case 0x14000008: return("recoverysequence");

                case 0x16000009: return("recoveryenabled");

                case 0x1700000A: return("badmemorylist");

                case 0x1600000B: return("badmemoryaccess");

                case 0x1500000C: return("firstmegabytepolicy");

                case 0x16000010: return("bootdebug");

                case 0x15000011: return("debugtype");

                case 0x15000012: return("debugaddress");

                case 0x15000013: return("debugport");

                case 0x15000014: return("baudrate");

                case 0x15000015: return("channel");

                case 0x12000016: return("targetname");

                case 0x16000017: return("noumex");

                case 0x15000018: return("debugstart");

                case 0x16000020: return("bootems");

                case 0x15000022: return("emsport");

                case 0x15000023: return("emsbaudrate");

                case 0x12000030: return("loadoptions");

                case 0x16000040: return("advancedoptions");

                case 0x16000041: return("optionsedit");

                case 0x15000042: return("keyringaddress");

                case 0x16000046: return("graphicsmodedisabled");

                case 0x15000047: return("configaccesspolicy");

                case 0x16000048: return("nointegritychecks");

                case 0x16000049: return("testsigning");

                case 0x16000050: return("extendedinput");

                case 0x15000051: return("initialconsoleinput");
                }
            }
            else if (idClass == ElementClass.Application)
            {
                switch (appType)
                {
                case ApplicationType.FirmwareBootManager:
                case ApplicationType.BootManager:
                    switch (identifier)
                    {
                    case 0x24000001: return("displayorder");

                    case 0x24000002: return("bootsequence");

                    case 0x23000003: return("default");

                    case 0x25000004: return("timeout");

                    case 0x26000005: return("resume");

                    case 0x23000006: return("resumeobject");

                    case 0x24000010: return("toolsdisplayorder");

                    case 0x26000020: return("displaybootmenu");

                    case 0x26000021: return("noerrordisplay");

                    case 0x21000022: return("bcddevice");

                    case 0x22000023: return("bcdfilepath");

                    case 0x27000030: return("customactions");
                    }

                    break;

                case ApplicationType.OsLoader:
                    switch (identifier)
                    {
                    case 0x21000001: return("osdevice");

                    case 0x22000002: return("systemroot");

                    case 0x23000003: return("resumeobject");

                    case 0x26000010: return("detecthal");

                    case 0x22000011: return("kernel");

                    case 0x22000012: return("hal");

                    case 0x22000013: return("dbgtransport");

                    case 0x25000020: return("nx");

                    case 0x25000021: return("pae");

                    case 0x26000022: return("winpe");

                    case 0x26000024: return("nocrashautoreboot");

                    case 0x26000025: return("lastknowngood");

                    case 0x26000026: return("oslnointegritychecks");

                    case 0x26000027: return("osltestsigning");

                    case 0x26000030: return("nolowmem");

                    case 0x25000031: return("removememory");

                    case 0x25000032: return("increaseuserva");

                    case 0x25000033: return("perfmem");

                    case 0x26000040: return("vga");

                    case 0x26000041: return("quietboot");

                    case 0x26000042: return("novesa");

                    case 0x25000050: return("clustermodeaddressing");

                    case 0x26000051: return("usephysicaldestination");

                    case 0x25000052: return("restrictapiccluster");

                    case 0x26000060: return("onecpu");

                    case 0x25000061: return("numproc");

                    case 0x26000062: return("maxproc");

                    case 0x25000063: return("configflags");

                    case 0x26000070: return("usefirmwarepcisettings");

                    case 0x25000071: return("msi");

                    case 0x25000072: return("pciexpress");

                    case 0x25000080: return("safeboot");

                    case 0x26000081: return("safebootalternateshell");

                    case 0x26000090: return("bootlog");

                    case 0x26000091: return("sos");

                    case 0x260000A0: return("debug");

                    case 0x260000A1: return("halbreakpoint");

                    case 0x260000B0: return("ems");

                    case 0x250000C0: return("forcefailure");

                    case 0x250000C1: return("driverloadfailurepolicy");

                    case 0x250000E0: return("bootstatuspolicy");
                    }

                    break;

                case ApplicationType.Resume:
                    switch (identifier)
                    {
                    case 0x21000001: return("filedevice");

                    case 0x22000002: return("filepath");

                    case 0x26000003: return("customsettings");

                    case 0x26000004: return("pae");

                    case 0x21000005: return("associatedosdevice");

                    case 0x26000006: return("debugoptionenabled");
                    }

                    break;

                case ApplicationType.MemoryDiagnostics:
                    switch (identifier)
                    {
                    case 0x25000001: return("passcount");

                    case 0x25000002: return("testmix");

                    case 0x25000003: return("failurecount");

                    case 0x25000004: return("testtofail");
                    }

                    break;

                case ApplicationType.NtLoader:
                case ApplicationType.SetupLoader:
                    switch (identifier)
                    {
                    case 0x22000001: return("bpbstring");
                    }

                    break;

                case ApplicationType.Startup:
                    switch (identifier)
                    {
                    case 0x26000001: return("pxesoftreboot");

                    case 0x22000002: return("applicationname");
                    }

                    break;
                }
            }
            else if (idClass == ElementClass.Device)
            {
                switch (identifier)
                {
                case 0x35000001: return("ramdiskimageoffset");

                case 0x35000002: return("ramdisktftpclientport");

                case 0x31000003: return("ramdisksdidevice");

                case 0x32000004: return("ramdisksdipath");

                case 0x35000005: return("ramdiskimagelength");

                case 0x36000006: return("exportascd");

                case 0x35000007: return("ramdisktftpblocksize");
                }
            }
            else if (idClass == ElementClass.Hidden)
            {
                switch (identifier)
                {
                case 0x45000001: return("devicetype");

                case 0x42000002: return("apprelativepath");

                case 0x42000003: return("ramdiskdevicerelativepath");

                case 0x46000004: return("omitosloaderelements");

                case 0x46000010: return("recoveryos");
                }
            }

            return(identifier.ToString("X8", CultureInfo.InvariantCulture));
        }
Exemple #40
0
        public void TestLongCodeDirectScopeIsIgnored(ApplicationType appType)
        {
            InitApiHelpers(appType);

            VerifyCodeDirectScope(Util.GetUniqueString(2048, false), appType);
        }
        public async Task Publish_And_Run_Tests(
            ServerType serverType,
            RuntimeArchitecture architecture,
            ApplicationType applicationType,
            bool noSource)
        {
            var noSourceStr = noSource ? "NoSource" : "WithSource";
            var testName    = $"PublishAndRunTests_{serverType}_{architecture}_{applicationType}_{noSourceStr}";

            using (StartLog(out var loggerFactory, testName))
            {
                var logger           = loggerFactory.CreateLogger("Publish_And_Run_Tests");
                var musicStoreDbName = DbUtils.GetUniqueName();

                var deploymentParameters = new DeploymentParameters(
                    Helpers.GetApplicationPath(applicationType), serverType, RuntimeFlavor.CoreClr, architecture)
                {
                    PublishApplicationBeforeDeployment       = true,
                    PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
                    TargetFramework       = "netcoreapp2.0",
                    Configuration         = Helpers.GetCurrentBuildConfiguration(),
                    ApplicationType       = applicationType,
                    UserAdditionalCleanup = parameters =>
                    {
                        DbUtils.DropDatabase(musicStoreDbName, logger);
                    }
                };

                // Override the connection strings using environment based configuration
                deploymentParameters.EnvironmentVariables
                .Add(new KeyValuePair <string, string>(
                         MusicStoreConfig.ConnectionStringKey,
                         DbUtils.CreateConnectionString(musicStoreDbName)));

                using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
                {
                    var deploymentResult = await deployer.DeployAsync();

                    var httpClientHandler = new HttpClientHandler()
                    {
                        UseDefaultCredentials = true
                    };
                    var httpClient = deploymentResult.CreateHttpClient(httpClientHandler);

                    // Request to base address and check if various parts of the body are rendered &
                    // measure the cold startup time.
                    // Add retry logic since tests are flaky on mono due to connection issues
                    var response = await RetryHelper.RetryRequest(async() => await httpClient.GetAsync(string.Empty), logger : logger, cancellationToken : deploymentResult.HostShutdownToken);

                    Assert.False(response == null, "Response object is null because the client could not " +
                                 "connect to the server after multiple retries");

                    var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);

                    logger.LogInformation("Verifying home page");
                    await validator.VerifyHomePage(response);

                    logger.LogInformation("Verifying static files are served from static file middleware");
                    await validator.VerifyStaticContentServed();

                    if (serverType != ServerType.IISExpress)
                    {
                        if (Directory.GetFiles(
                                deploymentParameters.ApplicationPath, "*.cmd", SearchOption.TopDirectoryOnly).Length > 0)
                        {
                            throw new Exception("publishExclude parameter values are not honored.");
                        }
                    }

                    logger.LogInformation("Variation completed successfully.");
                }
            }
        }
Exemple #42
0
        public void TestOauthValidInput(string redirect_url, string scope, string state, string response_type, ApplicationType appType)
        {
            InitApiHelpers(appType);
            var appInfo = GetDefaultApplication(appType);

            Dictionary <string, object> oauthParams = new Dictionary <string, object>()
            {
            };

            oauthParams.Add("app_id", appInfo.Key);

            if (null != redirect_url)
            {
                oauthParams.Add("redirect_url", redirect_url);
            }

            if (null != scope)
            {
                oauthParams.Add("scope", scope);
            }

            if (null != state)
            {
                oauthParams.Add("state", state);
            }

            if (null != response_type)
            {
                oauthParams.Add("response_type", response_type);
            }

            Handler handler = oAuthAPI.Read(oauthParams);

            Assert.That(handler.HttpCode, Is.EqualTo(System.Net.HttpStatusCode.OK), "The http code is invalid");

            APITestFramework.Resources.PublicAPI.Authentication result = XmlHelper.ParseXMLString <APITestFramework.Resources.PublicAPI.Authentication>(handler.RawContent);
            Assert.That(result, Is.Not.Null, "Failed to parse the server's response");
            if (response_type == "code_direct" && appType == ApplicationType.ThirdParty)
            {
                Assert.That(int.Parse(result.Error), Is.EqualTo(Enums.PublicAPIAuthCode.ResponseTypeInvalid), "Wrong error code. Received message: '" + result.Message + "', while expected 'Invalid Response Type' ");
            }
            else
            {
                Assert.That(int.Parse(result.Error), Is.EqualTo(Enums.PublicAPIAuthCode.Success), result.Message);
            }
        }
Exemple #43
0
 private static string pkParameterNameForAUCRatio(ApplicationType applicationType)
 {
     return(applicationType == ApplicationType.Multiple ? Constants.PKParameters.AUC_inf_tLast : Constants.PKParameters.AUC_inf);
 }
 public AttachmentControllerAdapter(ApplicationType type, Domain domain) : base(type, domain)
 {
 }
Exemple #45
0
 public IPKSimCommand SetApplicationType(ISchemaItem schemaItem, ApplicationType applicationType)
 {
     return(new SetSchemaItemApplicationTypeCommand(schemaItem, applicationType).Run(_executionContext));
 }
 /// <summary>
 /// 是否存在菜单
 /// </summary>
 /// <param name="parentNodeId">上级节点Id</param>
 /// <param name="applicationType">应用程序类型</param>
 /// <param name="menuName">菜单名称</param>
 /// <returns>是否存在</returns>
 public bool ExistsMenu(Guid?parentNodeId, ApplicationType applicationType, string menuName)
 {
     return(this._repMediator.MenuRep.Exists(parentNodeId, applicationType, menuName));
 }
Exemple #47
0
        private void VaryByArchitecture(List <TestVariant> variants, string tfm, string skip, ApplicationType type)
        {
            foreach (var arch in Architectures)
            {
                var archSkip = skip ?? SkipIfArchitectureNotSupportedOnCurrentSystem(arch);

                variants.Add(new TestVariant()
                {
                    Tfm             = tfm,
                    ApplicationType = type,
                    Architecture    = arch,
                    Skip            = archSkip,
                });
            }
        }
 /// <summary>
 /// 是否存在权限
 /// </summary>
 /// <param name="infoSystemNo">信息系统编号</param>
 /// <param name="applicationType">应用程序类型</param>
 /// <param name="authorityPath">权限路径</param>
 /// <returns>是否存在</returns>
 public bool ExistsAuthority(string infoSystemNo, ApplicationType applicationType, string authorityPath)
 {
     return(this._repMediator.AuthorityRep.ExistsPath(infoSystemNo, applicationType, authorityPath));
 }
        /// <summary>
        /// Ensures that the application configuration is valid.
        /// </summary>
        /// <param name="applicationType">Type of the application.</param>
        public virtual async Task Validate(ApplicationType applicationType)
        {
            if (String.IsNullOrEmpty(ApplicationName))
            {
                throw ServiceResultException.Create(StatusCodes.BadConfigurationError, "ApplicationName must be specified.");
            }

            if (SecurityConfiguration == null)
            {
                throw ServiceResultException.Create(StatusCodes.BadConfigurationError, "SecurityConfiguration must be specified.");
            }

            SecurityConfiguration.Validate();

            // load private key
            await SecurityConfiguration.ApplicationCertificate.LoadPrivateKeyEx(SecurityConfiguration.CertificatePasswordProvider);

            Func <string> generateDefaultUri = () => {
                var sb = new StringBuilder();
                sb.Append("urn:");
                sb.Append(Utils.GetHostName());
                sb.Append(":");
                sb.Append(ApplicationName);
                return(sb.ToString());
            };

            if (String.IsNullOrEmpty(ApplicationUri))
            {
                m_applicationUri = generateDefaultUri();
            }

            if (applicationType == ApplicationType.Client || applicationType == ApplicationType.ClientAndServer)
            {
                if (ClientConfiguration == null)
                {
                    throw ServiceResultException.Create(StatusCodes.BadConfigurationError, "ClientConfiguration must be specified.");
                }

                ClientConfiguration.Validate();
            }

            if (applicationType == ApplicationType.Server || applicationType == ApplicationType.ClientAndServer)
            {
                if (ServerConfiguration == null)
                {
                    throw ServiceResultException.Create(StatusCodes.BadConfigurationError, "ServerConfiguration must be specified.");
                }

                ServerConfiguration.Validate();
            }

            if (applicationType == ApplicationType.DiscoveryServer)
            {
                if (DiscoveryServerConfiguration == null)
                {
                    throw ServiceResultException.Create(StatusCodes.BadConfigurationError, "DiscoveryServerConfiguration must be specified.");
                }

                DiscoveryServerConfiguration.Validate();
            }

            // toggle the state of the hi-res clock.
            HiResClock.Disabled = m_disableHiResClock;

            if (m_disableHiResClock)
            {
                if (m_serverConfiguration != null)
                {
                    if (m_serverConfiguration.PublishingResolution < 50)
                    {
                        m_serverConfiguration.PublishingResolution = 50;
                    }
                }
            }

            await m_certificateValidator.Update(this.SecurityConfiguration);
        }
        //命令部分

        #region # 创建信息系统 —— void CreateInfoSystem(string infoSystemNo, string infoSystemName...
        /// <summary>
        /// 创建信息系统
        /// </summary>
        /// <param name="infoSystemNo">信息系统编号</param>
        /// <param name="infoSystemName">信息系统名称</param>
        /// <param name="adminLoginId">系统管理员账号</param>
        /// <param name="applicationType">应用程序类型</param>
        public void CreateInfoSystem(string infoSystemNo, string infoSystemName, string adminLoginId, ApplicationType applicationType)
        {
            #region # 验证

            if (this._repMediator.InfoSystemRep.ExistsNo(infoSystemNo))
            {
                throw new ArgumentOutOfRangeException(nameof(infoSystemNo), $"信息系统编号\"{infoSystemNo}\"已存在!");
            }
            if (this._repMediator.UserRep.ExistsNo(adminLoginId))
            {
                throw new ArgumentOutOfRangeException(nameof(adminLoginId), $"用户名:\"{adminLoginId}\"已存在!");
            }

            #endregion

            InfoSystem infoSystem      = new InfoSystem(infoSystemNo, infoSystemName, adminLoginId, applicationType);
            User       superAdmin      = this._unitOfWork.Resolve <User>(CommonConstants.AdminLoginId);
            User       systemAdmin     = new User(infoSystem.AdminLoginId, $"{infoSystem.Name}管理员", CommonConstants.InitialPassword);
            Role       systemAdminRole = new Role($"{infoSystem.Name}管理员", infoSystem.Number, null, infoSystem.Number);
            superAdmin.AppendRoles(new[] { systemAdminRole });
            systemAdmin.AppendRoles(new[] { systemAdminRole });
            Menu systemMenu = new Menu(infoSystem.Number, infoSystem.ApplicationType, infoSystem.Name, 0, null, null, null, null);

            this._unitOfWork.RegisterAdd(infoSystem);
            this._unitOfWork.RegisterAdd(systemAdmin);
            this._unitOfWork.RegisterAdd(systemAdminRole);
            this._unitOfWork.RegisterAdd(systemMenu);
            this._unitOfWork.RegisterSave(superAdmin);
            this._unitOfWork.Commit();
        }
 /// <summary>
 /// Loads and validates the application configuration from a configuration section.
 /// </summary>
 /// <param name="sectionName">Name of configuration section for the current application's default configuration containing <see cref="ConfigurationLocation"/>.</param>
 /// <param name="applicationType">Type of the application.</param>
 /// <returns>Application configuration</returns>
 public static Task <ApplicationConfiguration> Load(string sectionName, ApplicationType applicationType) =>
 Load(sectionName, applicationType, typeof(ApplicationConfiguration));
Exemple #52
0
 public IActionResult Create(ApplicationType obj)
 {
     _db.ApplicationType.Add(obj);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public void TestReadScopeOtherResourcesWithRegistedFullScope(string resource, ApplicationType appType)
        {
            InitFullScopeAdapter(appType);
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { Partition, appInfo.Company.Partition }
            };

            switch (resource)
            {
            case "user":
                parameters.Add("request_type", 1);
                ReadAndVerifyData <User>(adapter, parameters);
                break;

            case "partition":
                parameters.Add("request_type", 1);
                parameters.Remove(Partition);
                ReadAndVerifyData <Partition>(adapter, parameters);
                break;

            case "field":
                parameters.Add("resource", (int)Enums.ResourceType.Client);
                ReadAndVerifyData <Field>(adapter, parameters);
                break;

            case "option":
                ReadAndVerifyData <Option>(adapter, parameters);
                break;
            }
        }
        public void TestWriteScopeResourcesWithRegistedFullScope(Enums.ResourceType resourceType, ApplicationType appType)
        {
            InitFullScopeAdapter(appType);
            XmlResource resource = CreateResourceInstance(resourceType);
            string      id       = adapter.WriteSuccess(resource, cleaner.Delete);

            Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
Exemple #55
0
 /// <summary>
 /// Raises all RatePost events. These events are raised after a post is rated.
 /// </summary>
 public static void RatePost(Post post, ApplicationType appType)
 {
     CSApplication.Instance().ExecuteRatePostEvents(post,appType);
 }
Exemple #56
0
        private IParameterCollection GetParameterCollection(ApplicationDocumentation application, ApplicationType applicationType)
        {
            switch (applicationType)
            {
            case ApplicationType.SingleCommand:
                return(Assert.IsType <SingleCommandApplicationDocumentation>(application));

            case ApplicationType.MultiCommand:
                var mutliCommandApplication = Assert.IsType <MultiCommandApplicationDocumentation>(application);
                return(Assert.Single(mutliCommandApplication.Commands));

            default:
                throw new NotImplementedException();
            }
        }
Exemple #57
0
 /// <summary>
 /// Raises all BeforePost events. These events are raised before a post is commited to the datastore
 /// </summary>
 public static void BeforePost(Post post, ObjectState state, ApplicationType appType)
 {
     CSApplication.Instance().ExecutePrePostUpdateEvents(post,state,appType);
 }
Exemple #58
0
        public void Named_parameters_are_loaded_correctly(ApplicationType applicationType)
        {
            // ARRANGE
            using var assembly = Compile($@"
                using System;
                using CommandLine;

                public enum SomeEnum
                {{
                    Value1,
                    Value2,
                    SomeOtherValue
                }}

                {GetClassAttributes(applicationType)}
                public class Command1Options
                {{

                    [Option(""option1"", HelpText = ""some help text"", Default = ""some default"")]
                    public string Option1Property {{ get; set; }}

                    [Option('x', Default = 23)]
                    public int Option2Property {{ get; set; }}

                    [Option('y', Default = true)]
                    public bool? Option3Property {{ get; set; }}

                    [Option(""option4"", Hidden = true)]
                    public string Option4Property {{ get; set; }}

                    [Option(""option5"", Required = true, MetaValue = ""PATH"")]
                    public string Option5Property {{ get; set; }}

                    [Option('z', ""option6"")]
                    public SomeEnum Option6Property {{ get; set; }}

                    [Option(""option7"", Default = SomeEnum.SomeOtherValue)]
                    public SomeEnum Option7Property {{ get; set; }}

                    [Option(""option8"", Default = true)]
                    public bool? Option8Property {{ get; set; }}

                }}
            ");

            // ACT
            var sut = new CommandLineParserLoader(m_Logger);

            // ACT
            var application = sut.Load(assembly);

            // ASSERT
            Assert.NotNull(application);
            var parameterCollection = GetParameterCollection(application, applicationType);

            Assert.Empty(parameterCollection.SwitchParameters);
            Assert.Empty(parameterCollection.PositionalParameters);
            Assert.Collection(parameterCollection.NamedParameters,
                              param =>
            {
                Assert.Equal("option1", param.Name);
                Assert.Null(param.ShortName);
                Assert.Equal("some help text", param.Description);
                Assert.False(param.Required);
                Assert.Equal("some default", param.DefaultValue);
                Assert.Null(param.AcceptedValues);
                Assert.Null(param.ValuePlaceHolderName);
            },
                              param =>
            {
                Assert.Equal("option5", param.Name);
                Assert.Null(param.ShortName);
                Assert.Null(param.Description);
                Assert.True(param.Required);
                Assert.Null(param.DefaultValue);
                Assert.Null(param.AcceptedValues);
                Assert.Equal("PATH", param.ValuePlaceHolderName);
            },
                              param =>
            {
                Assert.Equal("option6", param.Name);
                Assert.Equal("z", param.ShortName);
                Assert.Null(param.Description);
                Assert.False(param.Required);
                Assert.Null(param.DefaultValue);
                Assert.NotNull(param.AcceptedValues);
                Assert.Equal(3, param.AcceptedValues !.Count);
                Assert.Contains("Value1", param.AcceptedValues);
                Assert.Contains("Value2", param.AcceptedValues);
                Assert.Contains("SomeOtherValue", param.AcceptedValues);
                Assert.Null(param.ValuePlaceHolderName);
            },
Exemple #59
0
 /// <summary>
 /// Creates an application object.
 /// </summary>
 /// <param name="imageType">The image type of the application.</param>
 /// <param name="appType">The application's type.</param>
 /// <returns>The object representing the new application.</returns>
 public BcdObject CreateApplication(ApplicationImageType imageType, ApplicationType appType)
 {
     Guid obj = _store.CreateObject(Guid.NewGuid(), BcdObject.MakeApplicationType(imageType, appType));
     return new BcdObject(_store, obj);
 }
Exemple #60
0
        public void TestOauthInvalidInput(string redirect_url, string scope, string state, string response_type, object errorCode, ApplicationType appType)
        {
            InitApiHelpers(appType);
            var appInfo = GetDefaultApplication(appType);

            Dictionary <string, object> oauthParams = new Dictionary <string, object>()
            {
            };

            oauthParams.Add("app_id", appInfo.Key);

            if (null != redirect_url)
            {
                oauthParams.Add("redirect_url", redirect_url);
            }

            if (null != scope)
            {
                oauthParams.Add("scope", scope);
            }

            if (null != state)
            {
                oauthParams.Add("state", state);
            }

            if (null != response_type)
            {
                oauthParams.Add("response_type", response_type);
            }

            Handler handler = oAuthAPI.Read(oauthParams);

            Assert.That(handler.HttpCode, Is.EqualTo(System.Net.HttpStatusCode.OK), "The http code is invalid");

            APITestFramework.Resources.PublicAPI.Authentication result = XmlHelper.ParseXMLString <APITestFramework.Resources.PublicAPI.Authentication>(handler.RawContent);
            Assert.That(result, Is.Not.Null, "Failed to parse the server's response");
            Assert.That(int.Parse(result.Error), Is.EqualTo(errorCode), result.Message);
        }