Ejemplo n.º 1
0
        public void VerifyInstances(Constants.UnitType unitType, Type type)
        {
            var     dataType     = new Type[] { type };
            var     genericBase  = typeof(MockInstance <>);
            var     combinedType = genericBase.MakeGenericType(dataType);
            dynamic instance     = Activator.CreateInstance(combinedType);
            dynamic service      = instance.GetService();

            Assert.Equal(unitType, service.UnitType);
        }
Ejemplo n.º 2
0
        public static T Spawn <T>(
            Constants.UnitType unitType,
            T prefab,
            Transform parent,
            StageCell cell,
            Constants.CardinalDirection direction) where T : Unit
        {
            var unit = Instantiate(prefab, cell.Tile.transform.position, prefab.transform.rotation);

            unit.transform.parent = parent;
            unit.Id   = _latestId++;
            unit.Cell = cell;
            unit.SetDirection(direction);
            unit.UnitType   = unitType;
            unit.UnitStatus = new UnitStatus();
            cell.Unit       = unit;

            return(unit);
        }
        public void AddUnit(Constants.UnitType unitType)
        {
            switch (unitType)
            {
            case Constants.UnitType.AzureAppConfig:
                ActiveBlueprintStorage.Blueprint.Units.Add(new UnitTypeAzureAppConfig());
                break;

            case Constants.UnitType.AzureKeyVault:
                ActiveBlueprintStorage.Blueprint.Units.Add(new UnitTypeAzureKeyVault());
                break;

            case Constants.UnitType.Blueprint:
                ActiveBlueprintStorage.Blueprint.Units.Add(new UnitTypeBlueprint());
                break;

            case Constants.UnitType.CommandPromptScript:
                ActiveBlueprintStorage.Blueprint.Units.Add(new UnitTypeCommandPromptScript());
                break;

            case Constants.UnitType.Documentation:
                ActiveBlueprintStorage.Blueprint.Units.Add(new UnitTypeDocumentation());
                break;

            case Constants.UnitType.EnvironmentVariable:
                ActiveBlueprintStorage.Blueprint.Units.Add(new UnitTypeEnvironmentVariable());
                break;

            case Constants.UnitType.PowerShellScript:
                ActiveBlueprintStorage.Blueprint.Units.Add(new UnitTypePowerShellScript());
                break;

            case Constants.UnitType.Workflow:
                ActiveBlueprintStorage.Blueprint.Units.Add(new UnitTypeWorkflow());
                break;

            default:
                UpdateStatus($"Whoops, unrecognized Unit type!");
                return;
            }
            OnUpdatedBlueprint?.Invoke(this, ActiveBlueprintStorage.Blueprint);
        }
Ejemplo n.º 4
0
        public async Task VerifyBlueprintLifeCycle(Constants.UnitFlag flag, Constants.UnitStage stage, Constants.UnitType type)
        {
            IBlueprint createdBlueprint = new Blueprint();

            createdBlueprint.Units.Add(new BaseBlueprintUnit()
            {
                UnitFlag  = flag,
                UnitState = stage,
                UnitType  = type
            });
            Guid createdId = createdBlueprint.Id;

            Assert.NotEqual(Guid.Empty, createdId);
            createdBlueprint.Name = "Some fantastical name!";
            string     json            = JsonConvert.SerializeObject(createdBlueprint);
            IBlueprint loadedBlueprint = JsonConvert.DeserializeObject <Blueprint>(json);

            Assert.Equal(createdId, loadedBlueprint.Id);
            Assert.Equal(createdBlueprint.Name, loadedBlueprint.Name);
            Assert.Equal(flag, loadedBlueprint.Units[0].UnitFlag);
            Assert.Equal(stage, loadedBlueprint.Units[0].UnitState);
            Assert.Equal(type, loadedBlueprint.Units[0].UnitType);
            Assert.False(await loadedBlueprint.Units[0].RunProcessor());
            Assert.False(await loadedBlueprint.Units[0].RunValidator());
        }
Ejemplo n.º 5
0
 public void VerifyDisplayNameOutput(string expectedDisplay, Constants.UnitType enumValue)
 {
     Assert.Equal(expectedDisplay, enumValue.DisplayName());
 }