Example #1
0
    public void SaveStub()
    {
        StubMsg msg = new StubMsg();

        var StubDatas = Role.Instance.GetStubDatas();

        foreach (var p in StubDatas)
        {
            StubNode[] stubList = null;
            int        stubCnt  = p.Key == _stubType ? mView.StubData.Count : p.Value.Count;
            switch (p.Key)
            {
            case StubType.PVE:
                stubList = msg.pve = new StubNode[stubCnt];
                break;

            case StubType.PVPAttack:
                stubList = msg.pvpattack = new StubNode[stubCnt];
                break;

            case StubType.PVPDefend:
                stubList = msg.pvpdefend = new StubNode[stubCnt];
                break;

            case StubType.March:
                stubList = msg.march = new StubNode[stubCnt];
                break;

            default:
                break;
            }
            if (p.Key == _stubType)
            {
                int stubidx = 0;
                foreach (var s in mView.StubData)
                {
                    StubNode node = new StubNode();
                    node.pos            = s.Key;
                    node.heroid         = s.Value;
                    stubList[stubidx++] = node;
                }
            }
            else
            {
                int stubidx = 0;
                foreach (var s in p.Value)
                {
                    StubNode node = new StubNode();
                    node.pos            = s.x;
                    node.heroid         = s.y;
                    stubList[stubidx++] = node;
                }
            }
        }

        Debug.LogFormat("SaveStub {0}", JsonUtility.ToJson(msg));
        Client.Instance.Send(Msg.ServerMsgId.CCMD_SAVE_FORMATION, msg, 0, Role.Instance.RoleId);
    }
            public void ShouldReturnParentOfSpecifiedNode_WhenPassedNodeHasParent()
            {
                // Given
                var underTest = new ParentModifier();
                var parent = new StubNode("Hello World");
                var child = new StubNode("Hello");
                parent.AppendChild(child);

                // When
                var result = underTest.ModifySelection(child);

                // Then
                Assert.That(result, Is.EquivalentTo(new[] {parent}));
            }
            public void ShouldReturnAllChildrenOfSpecifiedNode_WhenPassedNodeHasChildren()
            {
                // Given
                var underTest = new ChildrenModifier();
                var node = new StubNode("Hello World");
                node.AppendChild(new StubNode("Hello"));
                node.AppendChild(new StubNode("World"));

                // When
                var result = underTest.ModifySelection(node);

                // Then
                Assert.That(result, Is.EquivalentTo(new[] {new StubNode("Hello"), new StubNode("World")}));
            }
Example #4
0
            public void ShouldReturnAllChildrenOfSpecifiedNode_WhenPassedNodeHasChildren()
            {
                // Given
                var underTest = new ChildrenModifier();
                var node      = new StubNode("Hello World");

                node.AppendChild(new StubNode("Hello"));
                node.AppendChild(new StubNode("World"));

                // When
                var result = underTest.ModifySelection(node);

                // Then
                Assert.That(result, Is.EquivalentTo(new[] { new StubNode("Hello"), new StubNode("World") }));
            }
            public void ShouldReturnParentOfSpecifiedNode_WhenPassedNodeHasParent()
            {
                // Given
                var underTest = new ParentModifier();
                var parent    = new StubNode("Hello World");
                var child     = new StubNode("Hello");

                parent.AppendChild(child);

                // When
                var result = underTest.ModifySelection(child);

                // Then
                Assert.That(result, Is.EquivalentTo(new[] { parent }));
            }
            public void ShouldReturnSiblingsOfSpecifiedNode_WhenPassedNodeHasParent()
            {
                // Given
                var underTest = new SiblingsModifier();
                var parent = new StubNode("A");
                var child = new StubNode("C");

                parent.AppendChild(new StubNode("B"));
                parent.AppendChild(child);
                parent.AppendChild(new StubNode("D"));

                // When
                var result = underTest.ModifySelection(child);

                // Then
                Assert.That(result, Is.EquivalentTo(new[] {new StubNode("B"), new StubNode("D")}));
            }
Example #7
0
            public void ShouldReturnSiblingsOfSpecifiedNode_WhenPassedNodeHasParent()
            {
                // Given
                var underTest = new SiblingsModifier();
                var parent    = new StubNode("A");
                var child     = new StubNode("C");

                parent.AppendChild(new StubNode("B"));
                parent.AppendChild(child);
                parent.AppendChild(new StubNode("D"));

                // When
                var result = underTest.ModifySelection(child);

                // Then
                Assert.That(result, Is.EquivalentTo(new[] { new StubNode("B"), new StubNode("D") }));
            }
 /// <summary>
 /// Function that is called when a new Node is loaded.
 /// Checks the <see cref="TestNode.IsSuite"/> Property.
 /// Depending on the value it adds a <see cref="SuiteNode"/> or a <see cref="StubNode"/>
 /// </summary>
 /// <param name="node"><see cref="TestNode"/> to be added</param>
 private static void AddNode(TestNode node)
 {
     if (node.IsSuite)
     {
         var suite = new SuiteNode(node)
         {
             Assembly = _assembly
         };
         TestSuites.Add(suite);
         foreach (TestNode test in node.Tests)
         {
             AddNode(test);
         }
     }
     else
     {
         var test = new StubNode(node)
         {
             Assembly = _assembly
         };
         TestMethods.Add(test);
     }
 }