示例#1
0
        public void AddsSecretIdToProject()
        {
            var projectDir = _fixture.CreateProject(null);

            new InitCommand(null, null).Execute(MakeCommandContext(), projectDir);

            var idResolver = new ProjectIdResolver(MakeCommandContext().Reporter, projectDir);

            Assert.False(string.IsNullOrWhiteSpace(idResolver.Resolve(null, null)));
        }
示例#2
0
    public static string GetOrSetUserSecretsId(string projectFilePath)
    {
        var resolver = new ProjectIdResolver(NullReporter.Singleton, projectFilePath);
        var id       = resolver.Resolve(projectFilePath, configuration: null);

        if (string.IsNullOrEmpty(id))
        {
            return(UserSecretsCreator.CreateUserSecretsId(NullReporter.Singleton, projectFilePath, projectFilePath));
        }
        return(id);
    }
示例#3
0
    internal string ResolveId(CommandLineOptions options, IReporter reporter)
    {
        if (!string.IsNullOrEmpty(options.Id))
        {
            return(options.Id);
        }

        var resolver = new ProjectIdResolver(reporter, _workingDirectory);

        return(resolver.Resolve(options.Project, options.Configuration));
    }
示例#4
0
        public void DoesNotGenerateIdForProjectWithSecretId()
        {
            const string SecretId = "AlreadyExists";

            var projectDir = _fixture.CreateProject(SecretId);

            new InitCommand(null, null).Execute(MakeCommandContext(), projectDir);

            var idResolver = new ProjectIdResolver(MakeCommandContext().Reporter, projectDir);

            Assert.Equal(SecretId, idResolver.Resolve(null, null));
        }
示例#5
0
        public void AddsEscapedSpecificSecretIdToProject()
        {
            const string SecretId = @"<lots of XML invalid values>&";

            var projectDir = _fixture.CreateProject(null);

            new InitCommand(SecretId, null).Execute(MakeCommandContext(), projectDir);

            var idResolver = new ProjectIdResolver(MakeCommandContext().Reporter, projectDir);

            Assert.Equal(SecretId, idResolver.Resolve(null, null));
        }
示例#6
0
        public void AddsSpecificSecretIdToProject()
        {
            const string SecretId = "TestSecretId";

            var projectDir = _fixture.CreateProject(null);

            new InitCommand(SecretId, null).Execute(MakeCommandContext(), projectDir);

            var idResolver = new ProjectIdResolver(MakeCommandContext().Reporter, projectDir);

            Assert.Equal(SecretId, idResolver.Resolve(null, null));
        }