public void Successfully_RegisterAllFunctions() { var registry = new FunctionRegistry(); var cont = new FunctionContainer(2); registry.RegisterType(cont); Assert.IsTrue(registry.Contains("a", FunctionScope.Basic)); Assert.IsTrue(registry.Contains("b", FunctionScope.Global)); Assert.IsFalse(registry.Contains("c", FunctionScope.Global)); var conf = new RollerConfig() { FunctionRegistry = registry, GetRandomBytes = GetRNG(Roll9()) }; EvaluateRoll("1d20.a()", conf, 1, "1d20.a() => 9 => 10"); EvaluateRoll("1d20.b()", conf, 1, "1d20.b() => 9 => 11"); EvaluateRoll("b()", conf, 0, "b() => 2 => 2"); }
public void Successfully_RemoveFunction() { var registry = new FunctionRegistry(); registry.RegisterFunction("a", Invalid2.A, FunctionScope.All); Assert.IsTrue(registry.Contains("a", FunctionScope.Basic)); Assert.IsTrue(registry.Contains("a", FunctionScope.Group)); Assert.IsTrue(registry.Contains("a", FunctionScope.Global)); registry.Remove("a", FunctionScope.Basic); Assert.IsFalse(registry.Contains("a", FunctionScope.Basic)); Assert.IsTrue(registry.Contains("a", FunctionScope.Group)); Assert.IsTrue(registry.Contains("a", FunctionScope.Global)); }