public int GetTotalItemsQueuedStorageUsedByRoomDesign(RoomDesign roomDesign) { int num = 0; for (int index1 = 0; index1 < this.Rooms.Length; ++index1) { PSMainRoom room = this.Rooms[index1] as PSMainRoom; if (room.RoomStatus != RoomStatus.Inventory && room.RoomStatus != RoomStatus.Inventory && (room.RoomDesign.ItemRank == roomDesign.ItemRank && room.RoomDesign.ManufactureType == roomDesign.ManufactureType) && room.ManufactureString != string.Empty) { List <PSResourceGroup> psResourceGroupList = new List <PSResourceGroup>(); for (int index2 = 0; index2 < room.ManufactureItemQueue.Count; ++index2) { PSResourceGroup manufactureItem = room.ManufactureItemQueue[index2]; if (!psResourceGroupList.Contains(manufactureItem)) { psResourceGroupList.Add(manufactureItem); } } for (int index2 = 0; index2 < psResourceGroupList.Count; ++index2) { PSResourceGroup psResourceGroup = psResourceGroupList[index2]; ItemDesign itemDesignById = SingletonManager <ItemManager> .Instance.GetItemDesignByID(psResourceGroup.resourceId); num += itemDesignById.ItemSpace * psResourceGroup.quantity; } } } return(num); }
public void UpdatesSetPSResourceGroupWithTagFromId() { 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.Id = resourceGroupId; 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 void CreatesNewPSResourceGroup() { PSCreateResourceGroupParameters expectedParameters = new PSCreateResourceGroupParameters() { ResourceGroupName = resourceGroupName, Location = resourceGroupLocation, 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() { UpdatePSResourceGroupParameters expectedParameters = new UpdatePSResourceGroupParameters() { ResourceGroupName = resourceGroupName, Tag = tags.ToArray() }; UpdatePSResourceGroupParameters actualParameters = new UpdatePSResourceGroupParameters(); PSResourceGroup expected = new PSResourceGroup() { ResourceGroupName = expectedParameters.ResourceGroupName, Resources = new List <PSResource>() { new PSResource() { Name = "resource1" } }, Tags = expectedParameters.Tag }; resourcesClientMock.Setup(f => f.UpdatePSResourceGroup(It.IsAny <UpdatePSResourceGroupParameters>())) .Returns(expected) .Callback((UpdatePSResourceGroupParameters 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 void GetsResourcesGroups() { List <PSResourceGroup> result = new List <PSResourceGroup>(); PSResourceGroup expected = new PSResourceGroup() { Location = resourceGroupLocation, ResourceGroupName = resourceGroupName, Resources = new List <PSResource>() { new PSResource() { Name = "resource1" } } }; result.Add(expected); resourcesClientMock.Setup(f => f.FilterResourceGroups(resourceGroupName)).Returns(result); cmdlet.Name = resourceGroupName; cmdlet.ExecuteCmdlet(); Assert.Equal(1, result.Count); Assert.Equal(resourceGroupName, result[0].ResourceGroupName); Assert.Equal(resourceGroupLocation, result[0].Location); Assert.Equal(1, result[0].Resources.Count); 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, Resources = new List <PSResource>() { new PSResource() { Name = "resource1" } } }; 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); Assert.Equal(1, result[0].Resources.Count); }
public void CreatesNewPSResourceGroupWithUserTemplate() { CreatePSResourceGroupParameters expectedParameters = new CreatePSResourceGroupParameters() { ResourceGroupName = resourceGroupName, Location = resourceGroupLocation, TemplateFile = templateFile, DeploymentName = deploymentName, StorageAccountName = storageAccountName, TemplateVersion = "1.0", Tag = tags }; CreatePSResourceGroupParameters actualParameters = new CreatePSResourceGroupParameters(); PSResourceGroup expected = new PSResourceGroup() { Location = expectedParameters.Location, ResourceGroupName = expectedParameters.ResourceGroupName, Resources = new List <PSResource>() { new PSResource() { Name = "resource1" } }, Tags = expectedParameters.Tag }; resourcesClientMock.Setup(f => f.CreatePSResourceGroup(It.IsAny <CreatePSResourceGroupParameters>())) .Returns(expected) .Callback((CreatePSResourceGroupParameters p) => { actualParameters = p; }); cmdlet.Name = expectedParameters.ResourceGroupName; cmdlet.Location = expectedParameters.Location; cmdlet.TemplateFile = expectedParameters.TemplateFile; cmdlet.DeploymentName = expectedParameters.DeploymentName; cmdlet.TemplateVersion = expectedParameters.TemplateVersion; cmdlet.Tag = expectedParameters.Tag; cmdlet.ExecuteCmdlet(); Assert.Equal(expectedParameters.ResourceGroupName, actualParameters.ResourceGroupName); Assert.Equal(expectedParameters.Location, actualParameters.Location); Assert.Equal(expectedParameters.DeploymentName, actualParameters.DeploymentName); Assert.Equal(expectedParameters.GalleryTemplateIdentity, actualParameters.GalleryTemplateIdentity); Assert.Equal(expectedParameters.TemplateFile, actualParameters.TemplateFile); Assert.NotNull(actualParameters.TemplateParameterObject); Assert.Equal(expectedParameters.TemplateVersion, actualParameters.TemplateVersion); Assert.Equal(null, actualParameters.StorageAccountName); 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 static PSResourceGroup[] ParseRewardStrings(string theString) { if (string.IsNullOrWhiteSpace(theString)) { return(new PSResourceGroup[0]); } string[] strArray = theString.Split('|'); List <PSResourceGroup> psResourceGroupList = new List <PSResourceGroup>(); for (int index = 0; index < ((IEnumerable <string>)strArray).Count <string>(); ++index) { PSResourceGroup psResourceGroup = new PSResourceGroup(); psResourceGroup.ParseRewardString(strArray[index]); if (psResourceGroup.quantity > 0) { psResourceGroupList.Add(psResourceGroup); } } return(psResourceGroupList.ToArray()); }