public void AccelNodeTermOnly() { var filename = TestUtils.GetFilePath(@"Content\Test\Accel\Invalid\AccelNodeTermOnly.xml"); var pattern = new BulletPattern(); Assert.Throws <InvalidDataException>(() => pattern.Parse(filename)); }
public void DirectionNodeSequence2() { var filename = TestUtils.GetFilePath(@"Content\FireDirectionSequence2.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var actionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode; Assert.IsNotNull(actionNode); Assert.AreEqual(2, actionNode.ChildNodes.Count); var fireNode1 = actionNode.ChildNodes[0] as FireNode; var fireNode2 = actionNode.ChildNodes[1] as FireNode; Assert.IsNotNull(fireNode1); Assert.IsNotNull(fireNode2); var directionNode1 = fireNode1.GetChild(NodeName.direction) as DirectionNode; var directionNode2 = fireNode2.GetChild(NodeName.direction) as DirectionNode; Assert.IsNotNull(directionNode1); Assert.IsNotNull(directionNode2); Assert.AreEqual(NodeType.absolute, directionNode1.NodeType); Assert.AreEqual(NodeType.sequence, directionNode2.NodeType); }
public void FireDirectionSequence() { var filename = TestUtils.GetFilePath(@"Content\FireDirectionSequence2.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); Assert.AreEqual(1, mover.Tasks.Count); Assert.AreEqual(2, mover.Tasks[0].ChildTasks.Count); TestUtils.Manager.Update(); Assert.AreEqual(3, TestUtils.Manager.Movers.Count); var bullet1 = TestUtils.Manager.Movers[1] as Bullet; var bullet2 = TestUtils.Manager.Movers[2] as Bullet; Assert.IsNotNull(bullet1); Assert.IsNotNull(bullet2); Assert.AreEqual(90f, MathHelper.ToDegrees(bullet1.Direction)); Assert.AreEqual(MathHelper.ToDegrees(bullet1.Direction) + 10f, MathHelper.ToDegrees(bullet2.Direction)); }
public void AccelNodeVerticalHorizontal() { var filename = TestUtils.GetFilePath(@"Content\Test\Accel\Valid\AccelNodeVerticalHorizontal.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var topNode = pattern.RootNode.FindLabelNode("top", NodeName.action) as ActionNode; Assert.IsNotNull(topNode); Assert.AreEqual(1, topNode.ChildNodes.Count); var accelNode = topNode.ChildNodes[0] as AccelNode; Assert.IsNotNull(accelNode); Assert.AreEqual(3, accelNode.ChildNodes.Count); var verticalNode = accelNode.ChildNodes[0] as VerticalNode; var horizontalNode = accelNode.ChildNodes[1] as HorizontalNode; var termNode = accelNode.ChildNodes[2] as TermNode; Assert.IsNotNull(verticalNode); Assert.IsNotNull(horizontalNode); Assert.IsNotNull(termNode); }
public void CreatedSpeedNode() { var filename = TestUtils.GetFilePath(@"Content\FireSpeed.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); Assert.IsNotNull(pattern.RootNode); }
public void ValidXml() { var filename = TestUtils.GetFilePath(@"Content\BulletRef.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); Assert.IsNotNull(pattern.RootNode); }
public void TestIsParent() { var filename = TestUtils.GetFilePath(@"Content\Empty.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); Assert.AreEqual(pattern.RootNode.GetRootNode(), pattern.RootNode); }
public void ValidateTestData() { // Get all XML test files foreach (var source in Directory.GetFiles(TestUtils.GetFilePath("Content"), "*.xml")) { // Load and validate every patterns var pattern = new BulletPattern(); pattern.Parse(source); } }
public void CreatedBulletNode() { var filename = TestUtils.GetFilePath(@"Content\EmptyBullet.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); Assert.IsNotNull(pattern.RootNode); Assert.AreEqual(1, pattern.RootNode.ChildNodes.Count); }
public void CreatedBulletNode1() { var filename = TestUtils.GetFilePath(@"Content\EmptyBullet.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var testBulletNode = pattern.RootNode.GetChild(NodeName.bullet) as BulletNode; Assert.IsNotNull(testBulletNode); }
public void GotActionRefNode() { var filename = TestUtils.GetFilePath(@"Content\ActionRefEmpty.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode; Assert.IsNotNull(testActionNode); }
public void TestOneTop() { var filename = TestUtils.GetFilePath(@"Content\ActionOneTop.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var testNode = pattern.RootNode.FindLabelNode("top", NodeName.action) as ActionNode; Assert.IsNotNull(testNode); }
public void GotParamNode1() { var filename = TestUtils.GetFilePath(@"Content\FireRefParam.xml"); BulletPattern pattern = new BulletPattern(); pattern.Parse(filename); ActionNode testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode; FireRefNode testFireNode = testActionNode.GetChild(NodeName.fireRef) as FireRefNode; Assert.IsNotNull(testFireNode.GetChild(NodeName.param) as ParamNode); }
public void NotFinished() { var filename = TestUtils.GetFilePath(@"Content\ActionOneTop.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); Assert.IsFalse(mover.Tasks[0].Finished); }
public void NoParams() { var filename = TestUtils.GetFilePath(@"Content\ActionOneTop.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); Assert.AreEqual(0, mover.Tasks[0].Params.Count); }
public void OkFinished() { var filename = TestUtils.GetFilePath(@"Content\ActionOneTop.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); Assert.AreEqual(TaskRunStatus.End, mover.Tasks[0].Run(mover)); }
public void SetBulletLabelNode() { var filename = TestUtils.GetFilePath(@"Content\EmptyBullet.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var testBulletNode = pattern.RootNode.GetChild(NodeName.bullet) as BulletNode; Assert.IsNotNull(testBulletNode); Assert.AreEqual("test", testBulletNode.Label); }
public void CreatedSpeedNode3() { var filename = TestUtils.GetFilePath(@"Content\FireSpeed.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode; Assert.IsNotNull(testActionNode); var testFireNode = testActionNode.GetChild(NodeName.fire) as FireNode; Assert.IsNotNull(testFireNode); Assert.IsNotNull(testFireNode.GetChild(NodeName.speed) as SpeedNode); }
public void CreatedTopLevelFireNode() { var filename = TestUtils.GetFilePath(@"Content\FireEmpty.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var testFireNode = pattern.RootNode.GetChild(NodeName.fire) as FireNode; Assert.IsNotNull(testFireNode); Assert.IsNotNull(testFireNode.BulletDescriptionNode); Assert.AreEqual("test", testFireNode.Label); }
public void CorrectAction() { var filename = TestUtils.GetFilePath(@"Content\ActionRepeatOnce.xml"); BulletPattern pattern = new BulletPattern(); pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); BulletMLTask myTask = mover.Tasks[0]; Assert.AreEqual(1, myTask.ChildTasks.Count); }
public void CorrectNode() { var filename = TestUtils.GetFilePath(@"Content\ActionOneTop.xml"); BulletPattern pattern = new BulletPattern(); pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); Assert.IsNotNull(mover.Tasks[0].Node); Assert.IsNotNull(mover.Tasks[0].Node is ActionNode); }
public void RepeatNumMaxCorrect() { var filename = TestUtils.GetFilePath(@"Content\ActionRepeatMany.xml"); BulletPattern pattern = new BulletPattern(); pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); ActionTask testTask = mover.FindTaskByLabel("test") as ActionTask; Assert.IsNotNull(testTask); }
public void CreatedFireNode1() { var filename = TestUtils.GetFilePath(@"Content\FireRef.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); // Get the child action node var testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode; Assert.IsNotNull(testActionNode); Assert.IsNotNull(testActionNode.GetChild(NodeName.fireRef)); }
public void MakeSureNothingCrashes() { // Get all XML test files foreach (var source in Directory.GetFiles(TestUtils.GetFilePath("Content"), "*.xml")) { var pattern = new BulletPattern(); pattern.Parse(source); // Fire in the hole TestUtils.Manager.Movers.Clear(); var mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); } }
public void CreatedBulletRefNode2() { var filename = TestUtils.GetFilePath(@"Content\BulletRef.xml"); BulletPattern pattern = new BulletPattern(); pattern.Parse(filename); var testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode; Assert.IsNotNull(testActionNode); var testFireNode = testActionNode.GetChild(NodeName.fire) as FireNode; Assert.IsNotNull(testFireNode); Assert.IsNotNull(testFireNode.GetChild(NodeName.bulletRef)); }
public void RepeatOnce() { var filename = TestUtils.GetFilePath(@"Content\ActionOneTop.xml"); BulletPattern pattern = new BulletPattern(); pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); ActionTask myAction = mover.Tasks[0] as ActionTask; ActionNode testNode = pattern.RootNode.FindLabelNode("top", NodeName.action) as ActionNode; Assert.AreEqual(1, testNode.RepeatNum(myAction, mover)); }
public void RepeatNumMaxInitCorrect() { var filename = TestUtils.GetFilePath(@"Content\ActionRepeatOnce.xml"); BulletPattern pattern = new BulletPattern(); pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(pattern.RootNode); BulletMLTask myTask = mover.Tasks[0]; ActionTask testTask = myTask.ChildTasks[0] as ActionTask; ActionNode actionNode = testTask.Node as ActionNode; Assert.AreEqual(1, actionNode.RepeatNum(testTask, mover)); }
public void SpeedNodeDefaultValue() { var filename = TestUtils.GetFilePath(@"Content\FireSpeed.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode; Assert.IsNotNull(testActionNode); var testFireNode = testActionNode.GetChild(NodeName.fire) as FireNode; Assert.IsNotNull(testFireNode); var testSpeedNode = testFireNode.GetChild(NodeName.speed) as SpeedNode; Assert.IsNotNull(testSpeedNode); Assert.AreEqual(NodeType.absolute, testSpeedNode.NodeType); }
private void LoadPatternFile() { var pattern = new BulletPattern(); try { pattern.Parse(_patternFileInfos[_currentPattern].FullName); _patterns[_currentPattern] = pattern; _currentPatternErrors[_currentPattern] = null; } catch (Exception ex) { _currentPatternErrors.Insert(_currentPattern, ex.Message); } }
public void GotFireNode1() { var filename = TestUtils.GetFilePath(@"Content\FireRef.xml"); var pattern = new BulletPattern(); pattern.Parse(filename); var testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode; Assert.IsNotNull(testActionNode); var testFireNode = testActionNode.GetChild(NodeName.fireRef) as FireRefNode; Assert.IsNotNull(testFireNode); Assert.IsNotNull(testFireNode.ReferencedFireNode as FireNode); }