Exemple #1
0
        public void TestDeployDemoNoAzureOk()
        {
            // Arrange
            var postBody = new PostBody
            {
                id            = "someguid",
                instance      = "some-dyn-instance",
                username      = "******",
                password      = "******",
                email         = "*****@*****.**",
                resetInstance = false,
            };

            var environment = new ReleaseEnvironment();

            TestDeployDemo(postBody, environment);
        }
Exemple #2
0
        public void TestDeployAzureWithAzureOk()
        {
            // Arrange
            var postBody = new PostBody
            {
                id            = "1ba2fb0e-cca7-46c3-b926-7828f224a406",
                instance      = "some-dyn-instance",
                username      = "******",
                password      = "******",
                email         = "*****@*****.**",
                resetInstance = false,
            };

            var environment = new ReleaseEnvironment();

            environment.Variables.Add("azUniqueName", new ConfigurationVariableValue());
            environment.Variables.Add("azResourceGroup", new ConfigurationVariableValue());

            TestDeployDemo(postBody, environment);

            Assert.AreEqual(environment.Variables["azUniqueName"].Value, "somedyninstance");
            Assert.AreEqual(environment.Variables["azResourceGroup"].Value, "dd-somedyninstance-rg");
        }
Exemple #3
0
        public void TestDeployDemo(PostBody postBody, ReleaseEnvironment environment)
        {
            var(fakeRequest, fakeLog) = SetupPost(postBody);

            Environment.SetEnvironmentVariable("VstsUrl", "https://someaccount.visualstudio.com", EnvironmentVariableTarget.Process);

            var releaseDefinitions = JsonConvert.DeserializeObject <List <ReleaseDefinition> >(
                File.ReadAllText("GetReleaseDefinitionsResult.json")
                );

            var fakeReleaseHttpClientTestableWrapper = A.Fake <ReleaseHttpClientTestableWrapper>();

            A.CallTo(() =>
                     fakeReleaseHttpClientTestableWrapper.GetReleaseDefinitions(null, null)).WithAnyArguments()
            .Returns(releaseDefinitions);

            var release = new Release();

            release.Environments.Add(environment);

            environment.Variables.Add("dynDomain", new ConfigurationVariableValue());
            environment.Variables.Add("dynUser", new ConfigurationVariableValue());
            environment.Variables.Add("dynPassword", new ConfigurationVariableValue());
            environment.Variables.Add("dynTenant", new ConfigurationVariableValue());
            environment.Variables.Add("emailNotificationAddress", new ConfigurationVariableValue());
            environment.Variables.Add("resetInstance", new ConfigurationVariableValue());

            A.CallTo(() =>
                     fakeReleaseHttpClientTestableWrapper.CreateRelease(null, null, null)).WithAnyArguments()
            .Returns(release);

            A.CallTo(() =>
                     fakeReleaseHttpClientTestableWrapper.UpdateRelease(null, null, 0, null)).WithAnyArguments()
            .Returns(release);

            A.CallTo(() =>
                     fakeReleaseHttpClientTestableWrapper.UpdateReleaseResource(null, null, 0, null)).WithAnyArguments()
            .Returns(release);

            var fakeReleaseHttpClient = A.Fake <ReleaseHttpClient>(x => x.WithArgumentsForConstructor(() =>
                                                                                                      new ReleaseHttpClient(Settings.VstsUri, Settings.VstsCredential)));

            // Act
            var response = DeployDemo.TestableRun(fakeRequest, fakeLog,
                                                  fakeReleaseHttpClientTestableWrapper,
                                                  fakeReleaseHttpClient).Result;

            // Assert
            Assert.IsInstanceOfType(response, typeof(HttpResponseMessage));
            //var result = (OkObjectResult)response;
            var     jsonString = response.Content.ReadAsStringAsync().Result;
            dynamic r          = JsonConvert.DeserializeObject <JObject>(jsonString);

            //dynamic r = (JObject)result.Value;

            Assert.AreEqual((string)r.status, "success");
            Assert.AreEqual(environment.Variables["dynDomain"].Value, postBody.instance);
            Assert.AreEqual(environment.Variables["dynUser"].Value, "some");
            Assert.AreEqual(environment.Variables["dynPassword"].Value, postBody.password);
            Assert.AreEqual(environment.Variables["dynTenant"].Value, "user.com");
            Assert.AreEqual(environment.Variables["emailNotificationAddress"].Value, postBody.email);
            Assert.AreEqual(environment.Variables["resetInstance"].Value, postBody.resetInstance.ToString());
        }