コード例 #1
0
ファイル: HzAccountManger.cs プロジェクト: Veraatversus/HZBot
 /// <summary>Removes the account.</summary>
 /// <param name="account">The account.</param>
 public static void RemoveAccount(HzAccount account)
 {
     if (account != null && RemoveAccountCommand.CanExecute(account))
     {
         account.IsLogined = false;
         SynContext.Send((o) => Accounts.Remove(account), null);
     }
 }
コード例 #2
0
ファイル: UnitTest_Utils.cs プロジェクト: Reavenk/SynthSyntax
    /// <summary>
    /// A "contained" unit test is a synthsyn script has has all the data for the
    /// unit test contained within its scripts. Some of the test information isn't
    /// in the script logic itself, but within markup text in the comments
    /// </summary>
    /// <param name="filepath">The synthsyn file to load.</param>
    public static void PerformContainedTest(string filepath)
    {
        string cwd      = System.IO.Directory.GetCurrentDirectory();
        string fullPath = System.IO.Path.Combine(cwd, filepath);

        Debug.Log($"Starting contained unit test at {filepath}.");
        Debug.Log($"Using the full path {fullPath}");

        string       testName;
        List <int>   expected;
        List <float> expectedf;

        if (LoadContainTestMarkup(filepath, out testName, out expected, out expectedf) == false)
        {
            throw new System.Exception($"Test at {filepath} was expected to be contained, but is missing test information.");
        }

        if (expected == null && expectedf == null)
        {
            throw new System.Exception($"Test at {filepath} do not have expected answer keys to test against.");
        }

        using (var logScope = new SynLog.LogScope())
        {
            SynContext ctx = new SynContext();
            ctx.ParseFile(filepath);
            WASMBuild wasmBuild = new WASMBuild(ctx);
            byte[]    wasmBin   = wasmBuild.BuildWASM();

            System.IO.File.WriteAllBytes("test.Wasm", wasmBin);

            Module           mod = Module.LoadBinary(wasmBin);
            ExecutionContext exc = new ExecutionContext(mod, true);

            SetupTestingContext(exc);

            TestResults tr = StartTest();
            exc.RunFunction(mod.GetExportedFunction("DoTest"));

            if (expected != null)
            {
                tr.TestExpectations(expected.ToArray());
            }

            if (expectedf != null)
            {
                tr.TestExpectations(expectedf.ToArray());
            }
        }
    }
コード例 #3
0
ファイル: HzAccountManger.cs プロジェクト: Veraatversus/HZBot
 /// <summary>Adds the account.</summary>
 /// <param name="account">The account.</param>
 public static void AddAccount(HzAccount account)
 {
     SynContext.Send((o) => Accounts.Add(account), null);
 }