Ejemplo n.º 1
0
        public async Task CrudTests()
        {
            /// test for new event creation

            var eventService = ServiceProvider.GetService <IEventsService>();

            Assert.IsNotNull(eventService);

            var eventController = new EventsController(eventService);

            var item = new EventDto()
            {
                Name        = "event 1",
                Place       = "LN",
                ScheduledAt = DateTime.Today,
                CategoryId  = EventCategory.Concert
            };
            var result = await eventController.CreateEvents(item);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Id);
            Assert.IsTrue(result.Id != Guid.Empty);
            Assert.AreEqual(result.Name, item.Name);
            Assert.AreEqual(result.Place, item.Place);
            Assert.AreEqual(result.ScheduledAt, item.ScheduledAt);
            Assert.AreEqual(result.CategoryId, EventCategory.Concert);
        }
Ejemplo n.º 2
0
    public void OnGameStarted(Database.Database db, DateTime date,
                              GameDevCompany playedCompany)
    {
        database      = db;
        playerCompany = playedCompany;
        gameDateTime  = date;

        // load script functions
        scriptFunctions = Function <bool> .DefaultFunctions();

        scriptGlobalVariables = GameVariables();
        // additional local variables
        Assert.IsTrue(ScriptContext.AddLocalVariable(this,
                                                     "Employee_HiringCost", new FloatSymbol(0), true));
        Assert.IsTrue(ScriptContext.AddLocalVariable(this,
                                                     "Employee_Salary", new FloatSymbol(0), true));
        // parser context
        ParserContext parserContext = new ParserContext {
            Grammar         = Grammar.DefaultGrammar(),
            LocalVariables  = scriptVariables,
            GlobalVariables = scriptGlobalVariables,
            Functions       = scriptFunctions,
        };

        // test
        const string script     = @"
            //{
                let b: int = b;
            //}
            b
        ";
        Executable   executable = Executable.FromScript(script, parserContext);

        if (executable != null)
        {
            int result;
            executable.ExecuteExpecting(this, out result);
            Debug.LogWarning($"===> executable result = {result}");
        }

        // scripts parsing
        eventsController.CreateEvents(db.Events.Collection, parserContext);
        playerCompany.Init(database.Skills, parserContext);
        engineFeaturesController.CreateFeatures(db.EngineFeatures.Collection,
                                                parserContext);
        engineFeaturesController.CheckFeatures(this);
        newsController.CreateNews(db.News.Collection, date);

        // events OnInit calls
        Assert.IsTrue(eventsController.InitEvents(this));

        float    hiringCost;
        Employee employee = playedCompany.EmployeesManager.GenerateRandomEmployee(
            this,
            db.HiringMethod.FindById("CompSciGraduates"),
            db.Names.FindById("CommonNamesUSA"),
            db.Skills,
            out hiringCost);

        playedCompany.AddEmployee(employee);
        Debug.Log($"Generated Random Employee : hiring cost = {hiringCost}.");
    }