public void DynamicState_CreateEmpty_DoesNotThrowUponReadCalls() { DynamicState empty = DynamicState.CreateEmpty(10); // Arbitrary number Assert.DoesNotThrow(() => empty.GetEdge(2, 5)); Assert.DoesNotThrow(() => empty.GetEdge(1, 2)); Assert.DoesNotThrow(() => empty.GetEdge(7, 3)); DynamicState.AreaEdge e1 = empty.GetEdge(2, 5); DynamicState.AreaEdge e2 = empty.GetEdge(1, 2); DynamicState.AreaEdge e3 = empty.GetEdge(7, 3); Assert.DoesNotThrow(() => { bool b = e1.IsCausingClearEffect; }); Assert.DoesNotThrow(() => { bool b = e2.IsCausingPotentialEnemiesEffect; }); Assert.DoesNotThrow(() => { int i = e1.ToNodeId; }); for (int i = 0; i < 10; i++) { Assert.DoesNotThrow(() => empty.IsEnemyAreaReader()(i)); Assert.DoesNotThrow(() => empty.IsControlledByTeamReader()(i)); Assert.DoesNotThrow(() => empty.IsContestedAreaReader()(i)); Assert.DoesNotThrow(() => empty.TakingFireMagnitudeLevelReader()(i)); DynamicState.AreaNode n; Assert.DoesNotThrow(() => empty.GetNodeData(i)); n = empty.GetNodeData(i); Assert.DoesNotThrow(() => { int d = n.TakingFireMagnitudeLevel; }); Assert.DoesNotThrow(() => { bool b = n.IsControlledByTeam; }); Assert.DoesNotThrow(() => { Dictionary <FactType, Fact> f = DynamicStateInternalReader.GetNodeFact(i, empty); }); Assert.DoesNotThrow(() => { Dictionary <EffectType, EffectSum> f = DynamicStateInternalReader.GetNodeEffectSum(i, empty); }); } }
// Constructors public WorldRepresentation(StaticState staticState, DynamicState dynamicState = null, Interpretation interpretation = null) { StaticState = staticState ?? throw new ArgumentNullException("staticState", "ERROR: Tried to instantiate a new WorldRepresentation with no Static State. This is illegal because Dynamic-State information and Interpretation information both depend on Static State information"); if (dynamicState == null && interpretation != null) { throw new ArgumentNullException("dynamicState", "ERROR: Tried to instantiate a new WorldRepresentation with Interpretation but no Dynamic State. This is illegal because Interpretation information depends on Dynamic State information"); } DynamicState = dynamicState ?? DynamicState.CreateEmpty(staticState.NumberOfNodes); Interpretation = interpretation ?? Interpretation.CreateEmpty(staticState.NumberOfNodes); NumberOfNodes = staticState.NumberOfNodes; }