Example #1
0
        private static void AdaugaBun(AnabiContext context)
        {
            var bunuri = new AssetDb[]
            {
                new AssetDb()
                {
                    AddressId          = 1,
                    CategoryId         = 1,
                    CurrentStageId     = 1,
                    DecisionId         = 1,
                    IsDeleted          = false,
                    UserCodeAdd        = "pop",
                    AddedDate          = new DateTime(2017, 2, 3),
                    UserCodeLastChange = "maria",
                    LastChangeDate     = new DateTime(2017, 4, 5)
                },
                new AssetDb()
                {
                    AddressId          = 2,
                    CategoryId         = 2,
                    CurrentStageId     = 1,
                    DecisionId         = 1,
                    IsDeleted          = false,
                    UserCodeAdd        = "pop",
                    AddedDate          = new DateTime(2017, 3, 5),
                    UserCodeLastChange = "maria",
                    LastChangeDate     = new DateTime(2017, 4, 15)
                }
            };

            context.Bunuri.AddRange(bunuri);
            context.SaveChanges();
        }
Example #2
0
        private void AddAssets()
        {
            Console.Out.WriteLine("running add assets");
            var asset1 = new AssetDb()
            {
                Id      = AssetId,
                Address = new AddressDb()
                {
                    Street = "test street name",
                    City   = "Barcelona"
                }
            };
            var historicalStageDb1 = new HistoricalStageDb()
            {
                AddedDate   = DateTime.Now,
                UserCodeAdd = "test user code",
                Asset       = asset1
            };
            var asset2 = new AssetDb()
            {
                Id = EmptyAddressAssetId
            };
            var historicalStageDb2 = new HistoricalStageDb()
            {
                AddedDate   = DateTime.Now,
                UserCodeAdd = "test user code",
                Asset       = asset2
            };

            context.Assets.Add(asset1);
            context.Assets.Add(asset2);
            context.HistoricalStages.Add(historicalStageDb1);
            context.HistoricalStages.Add(historicalStageDb2);
            context.SaveChanges();
        }
        //- The Timeout attribute uses Time.timeScale.
        [UnityTest, Timeout(100000)] public IEnumerator HealthManager()
        {
            //- Our health component will take 1,000 seconds to go from zero to full. Let's speed things up by 10x
            Time.timeScale = 10;
            try {
                //- We don't need a specific scene, just load the custom assets
                AssetDb.Load <HealthManagerTranscript>("HealthManager.asset");
                var health = AssetDb.Load <Float>("Health.asset");
                //- Set to 0 since once a custom asset is loaded in the editor it stays loaded
                health.Set(0);
                //- It looks like forever, but the Timeout attribute will cause a test failure after 10 seconds
                while (true)
                {
                    //- This causes a 1/10th of a second delay due to the modified scale
                    yield return(new WaitForSeconds(1.0f));

                    //- Leaving once the test passes is a successful result. This should take 1 second at the current time scale.
                    if (health >= 0.01f)
                    {
                        yield break;
                    }
                }
            } finally {
                //- reset the time scale so other tests aren't effected.
                Time.timeScale = 1;
            }
        }
Example #4
0
        public async Task ShouldReturnAStoargeSpaceForAsset()
        {
            var entity = await AddAssetToStorageSpace();

            var asset = new AssetDb {
                Id = entity.AssetId
            };

            context.Assets.Add(asset);
            var storageSpace = new StorageSpaceDb {
                Id = entity.StorageSpaceId, Address = new AddressDb {
                    County = new CountyDb()
                }
            };

            context.StorageSpaces.Add(storageSpace);
            context.SaveChanges();

            var queryHandler = new GetStorageSpaceAssetHandler(BasicNeeds);

            var query = new GetAssetStorageSpace()
            {
                AssetId = entity.AssetId
            };

            var expected = await queryHandler.Handle(query, CancellationToken.None);

            Assert.IsTrue(expected.Count > 0);
        }
Example #5
0
        public override void Create()
        {
            if (LogEntries.HasErrors())
            {
                throw new Exception("Please fix compile errors first");
            }
            var files = AssetDb.FindByLabel("BuildNewService");

            using (var assets = AssetEditor.Instance) {
                var assetNames = new List <string>();
                foreach (string filePath in files)
                {
                    var dir        = Path.GetDirectoryName(filePath);
                    var assetName  = Path.GetFileNameWithoutExtension(filePath);
                    var scriptPath = $"{dir}/{assetName}.cs";
                    var monoScript = AssetDb.Load <MonoScript>(scriptPath);
                    var assetPath  = $"{dir}/{assetName}.asset";
                    if (!File.Exists(assetPath))
                    {
                        Debug.Log($"Building {assetPath}");
                        assetNames.Add(assetName);
                        var match     = namespaceRegex.Match(monoScript.text);
                        var nameSpace = match.Success ? match.Groups[1].Value : "";
                        assets.Add(assetName, nameSpace, assetPath);
                    }
                    AssetDatabase.ClearLabels(monoScript);
                }

                Environment mockEnvironment =
                    AssetDatabase.LoadAssetAtPath <Environment>("Assets/Askowl/Decoupler/Scripts/Environments/Mock.asset");

                foreach (var assetName in assetNames)
                {
                    var assetPath = assets.AssetPath(assetName);
                    var path      = Path.GetDirectoryName(assetPath);
                    var nameBase  = Path.GetFileNameWithoutExtension(path);
                    switch (assets.Asset(assetName))
                    {
                    case IServicesManager _:
                        assets
                        .SetFieldToAssetEditorEntry(assetName, "context", $"{nameBase}Context")
                        .InsertIntoArrayField(assetName, "services", $"{nameBase}ServiceForMock");
                        break;

                    case IContext _:
                        assets.SetField(assetName, "environment", mockEnvironment);
                        break;

                    case IServiceAdapter _:
//              var contextName = $"{nameBase}Context";
//              if (!assets.Exists(contextName)) assets.Load(contextName, Namespace(assetPath), path);
//              assets.SetFieldToAssetEditorEntry(assetName, "context", $"{nameBase}Context");
                        break;
                    }
                }
            }
        }
Example #6
0
        public static Fiber Go(string definitionAsset, string featureFile, string label = "")
        {
            var definitions = AssetDb.Load <Definitions>($"{definitionAsset}.asset");

            Assert.IsNotNull(definitions, $"Gherkin definitions asset '{definitionAsset}' not found");
            var fiber = Fiber.Instance()
                        .WaitFor(_ => definitions.Run(featureFile, label))
                        .Do(_ => Assert.IsTrue(definitions.Success, definitions.errorMessage))
                        .Log("<color=grey>Scenario Processing Complete</color>");

            fiber.Context(definitions);
            return(fiber);
        }
        [Step(@"^we prepare for a new service$")] public void PrepareNewService()
        {
            assetDb?.Dispose();
            assetDb = AssetDb.Instance;
            assetDb.CreateFolders(path: projectDirectory).Select();
            if (assetDb.Error)
            {
                Fail($"Can't create '{projectDirectory}'");
            }

            assetEditor?.Dispose();
            assetEditor = AssetEditor.Instance.Load(assetName: "NewService", nameSpace: "Decoupler", projectDirectory);
            newService  = (NewService)assetEditor.Asset("NewService");
            Clear();
        }
        public async Task <MinimalAssetViewModel> Handle(AddMinimalAsset message, CancellationToken cancellationToken)
        {
            var asset = new AssetDb()
            {
                Name        = message.Name,
                Description = message.Description,
                Identifier  = message.Identifier,
                CategoryId  = message.SubcategoryId,
                UserCodeAdd = UserCode(),
                AddedDate   = DateTime.Now,
                NrOfObjects = (int)message.Quantity,
                MeasureUnit = message.MeasureUnit,
                Remarks     = message.Remarks
            };

            var historicalStageDb = new HistoricalStageDb()
            {
                AddedDate               = DateTime.Now,
                StageId                 = message.StageId,
                UserCodeAdd             = UserCode(),
                EstimatedAmount         = message.EstimatedAmount,
                EstimatedAmountCurrency = message.EstimatedAmountCurrency
            };

            historicalStageDb.Asset = asset;

            context.Assets.Add(asset);
            context.HistoricalStages.Add(historicalStageDb);
            await context.SaveChangesAsync();

            var response = mapper.Map <AddMinimalAsset, MinimalAssetViewModel>(message);

            response.Id      = asset.Id;
            response.StageId = historicalStageDb.StageId;
            response.Journal = new JournalViewModel
            {
                UserCodeAdd        = asset.UserCodeAdd,
                AddedDate          = asset.AddedDate,
                UserCodeLastChange = asset.UserCodeLastChange,
                LastChangeDate     = asset.LastChangeDate,
            };

            return(response);
        }
Example #9
0
 public static void Add <T>(string name) where T : Manager => Add(name, AssetDb.Load <T>(name));
Example #10
0
 [MenuItem("Assets/Create/Decoupled/New Service")] private static void Start()
 {
     wizard.Value.basePath  = AssetDb.ProjectFolder();
     Selection.activeObject = wizard.Value;
     EditorGUI.FocusTextInControl("FirstWizardField");
 }