Ejemplo n.º 1
0
        public void CanCreateUpdateDeleteCredential()
        {
            using (var context = MockContext.Start(GetType().FullName))
            {
                using (var testFixture = new AutomationTestBase(context))
                {
                    var credentialName = TestUtilities.GenerateName("credential");
                    var userName       = "******";
                    var password       = "******";

                    var credential = testFixture.CreateCredential(credentialName, userName, password);
                    Assert.NotNull(credential);

                    credential = testFixture.GetCredential(credential.Name);
                    Assert.NotNull(credential);
                    Assert.Equal(userName, credential.UserName);

                    userName = "******";
                    password = "******";

                    credential.Description = "description of credential";
                    testFixture.UpdateCredential(credential, password, userName);
                    var credentials = testFixture.GetCredentials();

                    Assert.Single(credentials.ToList());
                    var updatedCredential = credentials.ToList()[0];
                    Assert.Equal(credential.UserName, updatedCredential.UserName);
                    Assert.Equal(credential.Description, updatedCredential.Description);

                    testFixture.DeleteCredential(credential.Name);

                    Assert.Throws <ErrorResponseException>(() =>
                    {
                        credential = testFixture.GetCredential(credential.Name);
                    });
                }
            }
        }