public void GetSourceContextFile_Param_Invalid() => Assert.Throws <FileNotFoundException> (() => AgentOptions.GetSourceContextFile(_sourceContext + "something"));
public void GetVersion_Null() => Assert.Null(AgentOptions.GetVersion(_unknownPlatform));
public void GetSourceContextFile_Param() => Assert.Equal(_sourceContext, AgentOptions.GetSourceContextFile(_sourceContext));
public void GetVersion_Platform() => Assert.Equal(_version, AgentOptions.GetVersion(_gaePlatform));
public void GetVersion_Env() => TestEnvVariable(() => AgentOptions.GetVersion(), AgentOptions.VersionEnvironmentVariable, "version-2");
private static string Serialize(AgentOptions options) { return(JsonConvert.SerializeObject(options)); }
public void GetModule_Null() => Assert.Null(AgentOptions.GetModule(_unknownPlatform));
public void GetProject_Null() => Assert.Null(AgentOptions.GetProject(_unknownPlatform));
public void GetModule_Platform() => Assert.Equal(_module, AgentOptions.GetModule(_gaePlatform));
public void GetProject_Platform() => Assert.Equal(_projectId, AgentOptions.GetProject(_gaePlatform));
public void GetProject_Env() => TestEnvVariable(() => AgentOptions.GetProject(), AgentOptions.ProjectEnvironmentVariable, "pid-2");
public void GetDebugger_Null() => Assert.Null(AgentOptions.GetDebugger());
public void GetDebugger_Env() => TestEnvVariable(() => AgentOptions.GetDebugger(), AgentOptions.DebuggerEnvironmentVariable, "some-path/to/a/debugger");
/// <summary> /// Adds the registry agent services to the collection. /// </summary> /// <param name="services">The service collection.</param> /// <param name="options">The agent options.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// services /// or /// options /// </exception> public static IServiceCollection AddServiceRegistryAgent(this IServiceCollection services, AgentOptions options) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } options.Validate(); services.AddSingleton(options); services.AddSingleton <IRegistryClient, RegistryClient>(); services.AddHttpClient(RegistryClient.HTTPCLIENT_NAME, client => { client.BaseAddress = options.Registry; client.DefaultRequestHeaders.Add("Accept", "application/json"); client.DefaultRequestHeaders.Add("User-Agent", $"ServiceRegistryClient - {Assembly.GetExecutingAssembly().GetName().Version} - {options.ServiceIdentifier}"); }); return(services); }
public void GetSourceContextFile_Env() => TestEnvVariable(() => AgentOptions.GetSourceContextFile(null), AgentOptions.SourceContextEnvironmentVariable, _sourceContext);
public void GetModule_Env() => TestEnvVariable(() => AgentOptions.GetModule(), AgentOptions.ModuleEnvironmentVariable, "service-2");
public void GetSourceContextFile_Null() => Assert.Null(AgentOptions.GetSourceContextFile(null));
public string ComputeChecksum(AgentOptions agentOptions) { return(CreateMd5(Serialize(agentOptions))); }