-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathConstantRegistryTests.cs
69 lines (56 loc) · 1.86 KB
/
ConstantRegistryTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jace.Execution;
#if NETFX_CORE
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
#elif __ANDROID__
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace Jace.Tests
{
[TestClass]
public class ConstantRegistryTests
{
[TestMethod]
public void TestAddConstant()
{
ConstantRegistry registry = new ConstantRegistry(false);
registry.RegisterConstant("test", 42.0);
ConstantInfo functionInfo = registry.GetConstantInfo("test");
Assert.IsNotNull(functionInfo);
Assert.AreEqual("test", functionInfo.ConstantName);
Assert.AreEqual(42.0, functionInfo.Value);
}
[TestMethod]
public void TestOverwritable()
{
ConstantRegistry registry = new ConstantRegistry(false);
registry.RegisterConstant("test", 42.0);
registry.RegisterConstant("test", 26.3);
}
[TestMethod]
public void TestNotOverwritable()
{
ConstantRegistry registry = new ConstantRegistry(false);
registry.RegisterConstant("test", 42.0, false);
AssertExtensions.ThrowsException<Exception>(() =>
{
registry.RegisterConstant("test", 26.3, false);
});
}
[TestMethod]
public void TestRemoveConstant()
{
ConstantRegistry registry = new ConstantRegistry(false);
registry.RegisterConstant("test", 42.0);
bool result = registry.UnregisterConstant("test");
Assert.IsTrue(result);
}
}
}