コード例 #1
0
 public MediaServiceAccountDetails(MediaServicesAccountGetResponse response)
 {
     this.AccountKeys = response.Account.StorageAccountKeys;
     this.Location = response.Account.AccountRegion;
     this.StorageAccountName = response.Account.StorageAccountName;
     this.Name = response.Account.AccountName;
 }
コード例 #2
0
        public void RegenerateMediaServicesAccountTest()
        {
            // Setup
            Mock<IMediaServicesClient> clientMock = new Mock<IMediaServicesClient>();

            const string newKey = "newkey";
            const string expectedName = "testacc";

            clientMock.Setup(f => f.RegenerateMediaServicesAccountAsync(expectedName, MediaServicesKeyType.Primary)).Returns(
                Task.Factory.StartNew(() => new OperationResponse { StatusCode = HttpStatusCode.OK }));

            MediaServicesAccountGetResponse detail = new MediaServicesAccountGetResponse
            {
                Account = new MediaServicesAccount {
                    AccountName = expectedName,
                    StorageAccountKeys = new MediaServicesAccount.AccountKeys
                    {
                        Primary = newKey
                    }
               }
            };

            clientMock.Setup(f => f.GetMediaServiceAsync(expectedName)).Returns(Task.Factory.StartNew(() => detail));

            // Test
            NewAzureMediaServiceKeyCommand command = new NewAzureMediaServiceKeyCommand
            {
                CommandRuntime = new MockCommandRuntime(),
                Name = expectedName,
                KeyType = MediaServicesKeyType.Primary,
                MediaServicesClient = clientMock.Object,
            };

            command.ExecuteCmdlet();
            Assert.Equal(1, ((MockCommandRuntime)command.CommandRuntime).OutputPipeline.Count);
            string key = (string)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
            Assert.Equal(newKey, key);
        }
コード例 #3
0
        public void ProcessGetMediaServiceByNameShouldReturnOneMatchingEntry()
        {
            Mock<IMediaServicesClient> clientMock = new Mock<IMediaServicesClient>();

            const string expectedName = "WAMS Account 1";
            MediaServicesAccountGetResponse detail = new MediaServicesAccountGetResponse
            {
                Account = new MediaServicesAccount() { AccountName = expectedName }
            };

            clientMock.Setup(f => f.GetMediaServiceAsync(detail.Account.AccountName)).Returns(Task.Factory.StartNew(() => detail));

            // Test
            GetAzureMediaServiceCommand getAzureMediaServiceCommand = new GetAzureMediaServiceCommand
            {
                CommandRuntime = new MockCommandRuntime(),
                MediaServicesClient = clientMock.Object,
                Name = expectedName
            };
            AzureSession.SetCurrentContext(new AzureSubscription { Id = new Guid(SubscriptionId) }, null, null);
            getAzureMediaServiceCommand.ExecuteCmdlet();
            Assert.Equal(1, ((MockCommandRuntime)getAzureMediaServiceCommand.CommandRuntime).OutputPipeline.Count);
            MediaServiceAccountDetails accounts = (MediaServiceAccountDetails)((MockCommandRuntime)getAzureMediaServiceCommand.CommandRuntime).OutputPipeline.FirstOrDefault();
            Assert.NotNull(accounts);
            Assert.Equal(expectedName, accounts.Name);
        }