public void CreatesNewPSResourceGroup()
        {
            PSCreateResourceGroupParameters expectedParameters = new PSCreateResourceGroupParameters()
            {
                ResourceGroupName = resourceGroupName,
                Location = resourceGroupLocation,
                TemplateFile = templateFile,
                DeploymentName = deploymentName,
                Tag = tags
            };
            PSCreateResourceGroupParameters actualParameters = new PSCreateResourceGroupParameters();
            PSResourceGroup expected = new PSResourceGroup()
            {
                Location = expectedParameters.Location,
                ResourceGroupName = expectedParameters.ResourceGroupName,
                Tags = expectedParameters.Tag
            };
            resourcesClientMock.Setup(f => f.CreatePSResourceGroup(It.IsAny<PSCreateResourceGroupParameters>()))
                .Returns(expected)
                .Callback((PSCreateResourceGroupParameters p) => { actualParameters = p; });

            cmdlet.Name = expectedParameters.ResourceGroupName;
            cmdlet.Location = expectedParameters.Location;
            cmdlet.Tag = expectedParameters.Tag;

            cmdlet.ExecuteCmdlet();

            Assert.Equal(expectedParameters.ResourceGroupName, actualParameters.ResourceGroupName);
            Assert.Equal(expectedParameters.Location, actualParameters.Location);
            Assert.Equal(expectedParameters.Tag, actualParameters.Tag);

            commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
        }
        public void UpdatesSetPSResourceGroupWithTag()
        {
            PSUpdateResourceGroupParameters expectedParameters = new PSUpdateResourceGroupParameters()
            {
                ResourceGroupName = resourceGroupName,
                Tag = tags
            };
            PSUpdateResourceGroupParameters actualParameters = new PSUpdateResourceGroupParameters();
            PSResourceGroup expected = new PSResourceGroup()
            {
                ResourceGroupName = expectedParameters.ResourceGroupName,
                Tags = expectedParameters.Tag
            };
            resourcesClientMock.Setup(f => f.UpdatePSResourceGroup(It.IsAny<PSUpdateResourceGroupParameters>()))
                .Returns(expected)
                .Callback((PSUpdateResourceGroupParameters p) => { actualParameters = p; });

            cmdlet.Name = expectedParameters.ResourceGroupName;
            cmdlet.Tag = expectedParameters.Tag;

            cmdlet.ExecuteCmdlet();

            Assert.Equal(expectedParameters.ResourceGroupName, actualParameters.ResourceGroupName);
            Assert.Equal(expectedParameters.Tag, actualParameters.Tag);

            commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
        }
        public static PSResourceGroup ToPSResourceGroup(this ResourceGroup resourceGroup)
        {
            var result = new PSResourceGroup
            {
                ResourceGroupName = resourceGroup.Name,
                Location = resourceGroup.Location,
                ProvisioningState = resourceGroup.Properties == null ? null : resourceGroup.Properties.ProvisioningState,
                Tags = TagsConversionHelper.CreateTagHashtable(resourceGroup.Tags),
                ResourceId = resourceGroup.Id
            };

            return result;
        }
        public void GetsResourcesGroups()
        {
            List<PSResourceGroup> result = new List<PSResourceGroup>();
            PSResourceGroup expected = new PSResourceGroup()
            {
                Location = resourceGroupLocation,
                ResourceGroupName = resourceGroupName
            };
            result.Add(expected);
            resourcesClientMock.Setup(f => f.FilterResourceGroups(resourceGroupName, null, false, null)).Returns(result);

            cmdlet.Name = resourceGroupName;

            cmdlet.ExecuteCmdlet();

            Assert.Equal(1, result.Count);
            Assert.Equal(resourceGroupName, result[0].ResourceGroupName);
            Assert.Equal(resourceGroupLocation, result[0].Location);

            commandRuntimeMock.Verify(f => f.WriteObject(result, true), Times.Once());
        }
        public void GetsResourcesGroupsById()
        {
            List<PSResourceGroup> result = new List<PSResourceGroup>();
            PSResourceGroup expected = new PSResourceGroup()
            {
                Location = resourceGroupLocation,
                ResourceGroupName = resourceGroupName
            };
            result.Add(expected);
            resourcesClientMock.Setup(f => f.FilterResourceGroups(null, null, true, null)).Returns(result);

            cmdlet.Id = resourceGroupId;

            cmdlet.ExecuteCmdlet();

            Assert.Equal(1, result.Count);
            Assert.Equal(resourceGroupName, result[0].ResourceGroupName);
            Assert.Equal(resourceGroupLocation, result[0].Location);
        }