public void GetSource_ThrowsOnInvalidSource(SourceType?type) { var source = new ServiceSource { Type = type }; Assert.Throws <InvalidOperationException>(() => source.GetSource()); }
public IServiceInstaller GetLocalDirectoryInstaller(ServiceSource source) { _ = source.ValidateLocalDirectory(options => options .IncludeProperties(x => x.Type) .ThrowOnFailures()); return(NoOpInstaller.Value); }
public void GetSource_ThrowsOnNotSupportedSource() { var source = new ServiceSource { Type = (SourceType)69 }; Assert.Throws <NotSupportedException>(() => source.GetSource()); }
public IServiceInstaller GetGitInstaller(ServiceSource source) { var gitSource = source.GetGitSource(); var repository = _services.GetRequiredService <IRepositoryFunctions>(); var progress = _services.GetRequiredService <IProgressReporter>(); return(new GitInstaller(gitSource.CloneUrl, repository, progress)); }
public Task <List <TPaymentDocumentEntity> > Get <TPaymentDocumentEntity>(ServiceTypes serviceType, ServiceSource serviceSource, string referenceCode) where TPaymentDocumentEntity : class, IPaymentDocumentEntity { return(_context.Set <TPaymentDocumentEntity>() .Where(i => i.ParentReferenceCode == referenceCode && i.ServiceType == serviceType && i.ServiceSource == serviceSource) .OrderByDescending(i => i.Date) .ToListAsync()); }
public void InferSourceType_InfersGit() { const SourceType expected = SourceType.Git; var source = new ServiceSource { CloneUrl = "url" }; var inferred = source.InferSourceType(); Assert.Equal(expected, inferred); }
public static ValidationResult Validate( this ServiceSource source, Action <ValidationStrategy <ServiceSource> >?options = null) { if (!source.TryInferSourceType(out var inferred)) { throw new NotSupportedException("Unable to infer source type to validate"); } return(source.Validate(inferred, options)); }
public void InferSourceType_InfersDockerImage() { const SourceType expected = SourceType.DockerImage; var source = new ServiceSource { ImageName = "image" }; var inferred = source.InferSourceType(); Assert.Equal(expected, inferred); }
public void InferSourceType_InfersDockerBuild() { const SourceType expected = SourceType.DockerBuild; var source = new ServiceSource { BuildContext = "context" }; var inferred = source.InferSourceType(); Assert.Equal(expected, inferred); }
public void InferSourceType_ReturnsTypeWhenSet() { const SourceType expected = (SourceType)69; var source = new ServiceSource { Type = expected }; var inferred = source.InferSourceType(); Assert.Equal(expected, inferred); }
public void TryInferSourceType_ReturnsTrueWhenSourceWasInferred() { const SourceType expected = SourceType.Git; var source = new ServiceSource { CloneUrl = "url" }; var result = source.TryInferSourceType(out var inferred); Assert.True(result); Assert.Equal(expected, inferred); }
public void InferSourceType_SetsTypeOnOutParameter() { const SourceType expected = SourceType.Git; var source = new ServiceSource { CloneUrl = "url" }; _ = source.InferSourceType(out var updated); Assert.Equal(expected, updated.Type); Assert.NotEqual(source, updated); }
public void TryGetSource_GetsInvalidSource(SourceType?type) { var source = new ServiceSource { Type = type }; var result = source.TryGetSource(out var converted); Assert.False(result); var(serviceSource, errors) = Assert.IsType <InvalidSource>(converted); Assert.Equal(source, serviceSource); Assert.NotEmpty(errors); }
public void GetSource_GetsGitSource() { var source = new ServiceSource { Type = SourceType.Git, CloneUrl = "https://example.com/repo.git" }; var result = source.GetSource(); var git = Assert.IsType <GitSource>(result); Assert.Equal(source.CloneUrl, git.CloneUrl); }
private static OkObjectResult AcequireToken(ServiceSource service) { if (service == ServiceSource.Amval) { string username = "******"; string password = "******"; RestClient client = new RestClient("http://192.168.0.16:1002"); IRestResponse <TokenString> token = GetToken(username, password, client, "/api/Login"); client.Authenticator = new JwtAuthenticator(token.Data.token); return(new TestCtrl().Ok(token.Data.token)); } throw new Exception(); }
public void GetSource_GetsDotnetToolSource() { var source = new ServiceSource { Type = SourceType.DotnetTool, ToolName = "tool", ExtraArgs = "args" }; var result = source.GetSource(); var(_, toolName, extraArgs) = Assert.IsType <DotnetToolSource>(result); Assert.Equal(source.ToolName, toolName); Assert.Equal(source.ExtraArgs, extraArgs); }
public void GetSource_GetsDockerBuildSource() { var source = new ServiceSource { Type = SourceType.DockerBuild, BuildContext = "context", Tag = "tag", }; var result = source.GetSource(); var(_, buildContext, tag) = Assert.IsType <DockerBuildSource>(result); Assert.Equal(source.BuildContext, buildContext); Assert.Equal(source.Tag, tag); }
public void GetSource_GetsDockerImageSource() { var source = new ServiceSource { Type = SourceType.DockerImage, ImageName = "image", Tag = "tag", }; var result = source.GetSource(); var(_, imageName, tag) = Assert.IsType <DockerImageSource>(result); Assert.Equal(source.ImageName, imageName); Assert.Equal(source.Tag, tag); }
private static ValidateOptionsResult Validate(ServiceSource source) { if (source == null) { return(ValidateOptionsResult.Skip); } return(source.Type switch { SourceType.Git => ValidateGit(source), SourceType.DotnetTool => ValidateDotnetTool(source), SourceType.LocalDirectory => ValidateLocalDirectory(source), null => ValidateOptionsResult.Fail("Source type not configured"), _ => ValidateOptionsResult.Fail("Invalid source type") });
public static OkObjectResult GetToken(ServiceSource Service) { if (!Tokens.ContainsKey(Service)) { Tokens[Service] = new TokenData { Token = AcequireToken(Service) } } ; if (DateTime.Now > Tokens[Service].ExpireTime) { Tokens[Service] = new TokenData { Token = AcequireToken(Service), ExpireTime = DateTime.Now.Add(new TimeSpan(0, 115, 0)) } } ; return(Tokens[Service].Token); }
public Service(ServiceDescription description, ServiceSource source) { Description = description; Logs.Subscribe(entry => { if (CachedLogs.Count > 5000) { CachedLogs.TryDequeue(out _); } CachedLogs.Enqueue(entry); }); ReplicaEvents.Subscribe(entry => { entry.Replica.State = entry.State; }); ServiceSource = source; }
public ExternalServiceBuilder(string name, ServiceSource source) : base(name, source) { }
public AzureFunctionServiceBuilder(string name, string path, ServiceSource source) : base(name, source) { FunctionPath = path; }
public DotnetProjectServiceBuilder(string name, FileInfo projectFile, ServiceSource source) : base(name, source) { ProjectFile = projectFile; }
public LaunchedServiceBuilder(string name, ServiceSource source) : base(name, source) { }
public ProjectServiceBuilder(string name, ServiceSource source) : base(name, source) { }
public static IServiceInstaller GetInstaller(this IServiceInstallerFactory factory, ServiceSource source) => source.InferSourceType() switch {
public static SourceType?InferSourceType(this ServiceSource source) => source switch { { Type : not null } => source.Type,
public ContainerServiceBuilder(string name, string image, ServiceSource source) : base(name, source) { Image = image; }
public ExecutableServiceBuilder(string name, string executable, ServiceSource source) : base(name, source) { Executable = executable; }