Ejemplo n.º 1
0
 public SetCommand(SetOptions options, ReleaseTransformer releaseTransformer, VariableContainerTransformer variableContainerTransformer, IUrlStore urlStore, IAzureClient azureClient, IOutput output)
 {
     _options                      = options;
     _releaseTransformer           = releaseTransformer;
     _variableContainerTransformer = variableContainerTransformer;
     _urlStore                     = urlStore;
     _azureClient                  = azureClient;
     _output = output;
 }
Ejemplo n.º 2
0
        public void UpdateRelease_ThrowsArgumentNullException_IfNewValuesReleaseJsonIsEmpty()
        {
            // Arrange
            string existingJson       = "{}";
            string newValuesJson      = null;
            var    releaseTransformer = new ReleaseTransformer();

            // Act
            Assert.Throws <ArgumentNullException>(() => releaseTransformer.UpdateRelease(existingJson, newValuesJson));

            // Assert
        }
Ejemplo n.º 3
0
        public void UpdateRelease_UpdatesCorrectEnvironment()
        {
            // Arrange
            var release  = CreatePartiallyValidRelease();
            var envArray = new JArray();
            var env1     = new JObject();

            env1["id"]        = 1;
            env1["variables"] = new JObject();
            var env2 = new JObject();

            env2["id"]        = 2;
            env2["variables"] = new JObject();
            envArray.Add(env1);
            envArray.Add(env2);
            release["environments"] = envArray;
            var releaseVariables = new ReleaseVariables
            {
                Variables    = new Dictionary <string, Variable>(),
                Environments = new List <PipelineEnvironment>
                {
                    new PipelineEnvironment
                    {
                        Id        = 2,
                        Variables = new Dictionary <string, Variable>
                        {
                            { "Variable1", new Variable
                              {
                                  Value = "Value"
                              } }
                        }
                    }
                }
            };
            var releaseTransformer = new ReleaseTransformer();

            // Act
            var output = releaseTransformer.UpdateRelease(JsonConvert.SerializeObject(release),
                                                          JsonConvert.SerializeObject(releaseVariables));

            // Assert
            Assert.Equal("Value", JsonConvert.DeserializeObject <JObject>(output)
                         .SelectToken($"$.environments[?(@.id == 2)].variables")["Variable1"]
                         .ToObject <Variable>()
                         .Value);
        }
Ejemplo n.º 4
0
        public void UpdateRelease_ThrowsArgumentException_WhenEnvironmentDoesntExist()
        {
            // Arrange
            var release          = CreatePartiallyValidRelease();
            var releaseVariables = new ReleaseVariables
            {
                Variables    = new Dictionary <string, Variable>(),
                Environments = new List <PipelineEnvironment>
                {
                    new PipelineEnvironment
                    {
                        Id = 1
                    }
                }
            };
            var releaseTransformer = new ReleaseTransformer();

            // Act
            Assert.Throws <ArgumentException>(() => releaseTransformer.UpdateRelease(JsonConvert.SerializeObject(release),
                                                                                     JsonConvert.SerializeObject(releaseVariables)));

            // Assert
        }