public void RegenerateMediaServicesAccountTest()
        {
            // Setup
            var clientMock = new Mock<IMediaServicesClient>();

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

            clientMock.Setup(f => f.RegenerateMediaServicesAccountAsync(expectedName, "Primary")).Returns(Task.Factory.StartNew(() => true));

            var detail = new MediaServiceAccountDetails
            {
                Name = expectedName,
                AccountKeys = new AccountKeys
                {
                    Primary = newKey
                }
            };

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

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

            command.ExecuteCmdlet();
            Assert.AreEqual(1, ((MockCommandRuntime) command.CommandRuntime).OutputPipeline.Count);
            var key = (string) ((MockCommandRuntime) command.CommandRuntime).OutputPipeline.FirstOrDefault();
            Assert.AreEqual(newKey, key);
        }
        public void ProcessGetMediaServiceByNameShouldReturnOneMatchingEntry()
        {
            var clientMock = new Mock<IMediaServicesClient>();

            string expectedName = "WAMS Account 1";
            var detail = new MediaServiceAccountDetails
            {
                Name = expectedName
            };

            clientMock.Setup(f => f.GetMediaServiceAsync(detail.Name)).Returns(Task.Factory.StartNew(() => { return detail; }));

            // Test
            var getAzureMediaServiceCommand = new GetAzureMediaServiceCommand
            {
                CommandRuntime = new MockCommandRuntime(),
                MediaServicesClient = clientMock.Object,
                CurrentSubscription = new SubscriptionData
                {
                    SubscriptionId = SubscriptionId
                }
            };
            getAzureMediaServiceCommand.Name = expectedName;
            getAzureMediaServiceCommand.ExecuteCmdlet();
            Assert.AreEqual(1, ((MockCommandRuntime) getAzureMediaServiceCommand.CommandRuntime).OutputPipeline.Count);
            var accounts = (MediaServiceAccountDetails) ((MockCommandRuntime) getAzureMediaServiceCommand.CommandRuntime).OutputPipeline.FirstOrDefault();
            Assert.IsNotNull(accounts);
            Assert.AreEqual(expectedName, accounts.Name);
        }