Esempio n. 1
0
        private async Task <string> TransformObject(string existing)
        {
            string newValue = existing;

            switch (_options.Type)
            {
            case AvmObjectType.Build:
                break;

            case AvmObjectType.Release:
                break;

            case AvmObjectType.BuildVariables:
            case AvmObjectType.VariableGroupVariables:
                var newVariables = await File.ReadAllTextAsync(_options.SourceFilePath,
                                                               Encoding.UTF8);

                newValue = _variableContainerTransformer.UpdateContainer(existing, newVariables);
                break;

            case AvmObjectType.ReleaseVariables:
                newValue = _releaseTransformer.UpdateRelease(existing,
                                                             await File.ReadAllTextAsync(_options.SourceFilePath, Encoding.UTF8));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(newValue);
        }
Esempio n. 2
0
        public void UpdateContainer_ThrowsArgumentNullException_IfNewVariablesIsNull()
        {
            // Arrange
            var    transformer           = new VariableContainerTransformer();
            var    existingContainerJson = "{}";
            string newVariables          = null;

            // Act
            Assert.Throws <ArgumentNullException>(() => transformer.UpdateContainer(existingContainerJson, newVariables));

            // Assert
        }
Esempio n. 3
0
        public void UpdateContainer_UpdatesVariableAllowOverride()
        {
            // Arrange
            var build     = CreateValidPartialBuild();
            var variables = new Dictionary <string, Variable>
            {
                { "Variable1", new Variable {
                      IsSecret = true
                  } }
            };
            var transformer = new VariableContainerTransformer();

            // Act
            var output        = transformer.UpdateContainer(JsonConvert.SerializeObject(build), JsonConvert.SerializeObject(variables));
            var outputJObject = JsonConvert.DeserializeObject <JObject>(output);

            // Assert
            Assert.Equal(true, outputJObject["variables"]["Variable1"].ToObject <Variable>().IsSecret);
        }