changeset 13:4c8932dad7b2

Add Test and only NetworkTreeOperationLogTest.cs not work.
author Kazuma
date Sun, 23 Oct 2016 13:35:21 +0900
parents b71d9ea6bd8e
children e07d8f241630
files src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkNodePath.cs src/test/csharp/jp.ac.u-ryukyu.ie.cr/junge-main/data/treemap/TreeMapTest.cs src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkAppendChildOperationTest.cs src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkDeleteAttributeOperationTest.cs src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkDeleteChildAtOperationTest.cs src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkNodeOperationTest.cs src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkPutAttributeOperationTest.cs src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkTreeOperationLogTest.cs
diffstat 8 files changed, 124 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkNodePath.cs	Sun Oct 23 12:25:57 2016 +0900
+++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkNodePath.cs	Sun Oct 23 13:35:21 2016 +0900
@@ -21,10 +21,6 @@
 		this.Path = path;
 	}
 
-	public IEnumerator<int> iterator () { // iterator error. 
-		yield return this.Path.GetEnumerator().Current;
-	}
-
 	IEnumerator IEnumerable.GetEnumerator()
 	{
 		return this.GetEnumerator();
@@ -32,7 +28,7 @@
 
 	public IEnumerator<int> GetEnumerator()
 	{
-		return iterator ();
+		yield return this.Path.GetEnumerator().Current;
 	}
 
 	public NodePath add (int pos) {
--- a/src/test/csharp/jp.ac.u-ryukyu.ie.cr/junge-main/data/treemap/TreeMapTest.cs	Sun Oct 23 12:25:57 2016 +0900
+++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/junge-main/data/treemap/TreeMapTest.cs	Sun Oct 23 13:35:21 2016 +0900
@@ -14,17 +14,6 @@
 
 
 		}
-
-//		for (int count = 100; count > -10; count--) {
-//			ReturnNumber = map.get(count);
-//			if(ReturnNumber == null){
-//				checknull = false;
-//			}
-//			//this points null check.
-//			  if (checknull){
-//				Debug.Log(map.get());
-//		}
-		Debug.Log ("end");
 	
 	}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkAppendChildOperationTest.cs	Sun Oct 23 13:35:21 2016 +0900
@@ -0,0 +1,18 @@
+using UnityEngine;
+using System.Collections;
+using MsgPack;
+
+public class NetworkAppendChildOperationTest : MonoBehaviour {
+
+	// Use this for initialization
+	void Start () {
+		NetworkAppendChildAtOperation op = new NetworkAppendChildAtOperation(1);
+		ObjectPacker pack = new ObjectPacker();
+		byte[] value = pack.Pack(op);
+
+		// unpackage
+		ObjectPacker unpack = new ObjectPacker();
+		NetworkAppendChildAtOperation mOp = unpack.Unpack<NetworkAppendChildAtOperation>(value);
+		print(mOp.getPosition()); // add position 1 , get what number?
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkDeleteAttributeOperationTest.cs	Sun Oct 23 13:35:21 2016 +0900
@@ -0,0 +1,18 @@
+using UnityEngine;
+using System.Collections;
+using MsgPack;
+
+public class NetworkDeleteAttributeOperationTest : MonoBehaviour {
+
+	// Use this for initialization
+	void Start () {
+		NetworkDeleteAttributeOperation op = new NetworkDeleteAttributeOperation("hoge");
+		ObjectPacker pack = new ObjectPacker();
+		byte[] value = pack.Pack(op);
+
+		// unpackage
+		ObjectPacker unpack = new ObjectPacker();
+		NetworkDeleteAttributeOperation mOp = unpack.Unpack<NetworkDeleteAttributeOperation>(value);
+		print(mOp.getKey());
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkDeleteChildAtOperationTest.cs	Sun Oct 23 13:35:21 2016 +0900
@@ -0,0 +1,19 @@
+using UnityEngine;
+using System.Collections;
+using MsgPack;
+
+public class NetworkDeleteChildAtOperationTest : MonoBehaviour {
+
+	// Use this for initialization
+	void Start () {
+		NetworkDeleteChildAtOperation op = new NetworkDeleteChildAtOperation(1);
+		ObjectPacker pack = new ObjectPacker();
+		byte[] value = pack.Pack(op);
+
+		// unpackage
+		ObjectPacker unpack = new ObjectPacker();
+		NetworkDeleteChildAtOperation mOp = unpack.Unpack<NetworkDeleteChildAtOperation>(value);
+		print(mOp.getPosition());
+		print(mOp.getCommand());
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkNodeOperationTest.cs	Sun Oct 23 13:35:21 2016 +0900
@@ -0,0 +1,20 @@
+using UnityEngine;
+using System.Collections;
+using MsgPack;
+
+public class NetworkNodeOperationTest : MonoBehaviour {
+
+	// Use this for initialization
+	void Start () {
+		NetworkAppendChildAtOperation op = new NetworkAppendChildAtOperation(3);
+		NetworkNodeOperation nOp = new NetworkNodeOperation(op);
+
+		ObjectPacker pack = new ObjectPacker();
+		byte[] value = pack.Pack(nOp);
+
+		ObjectPacker unpack = new ObjectPacker();
+		NetworkNodeOperation mnp = unpack.Unpack<NetworkNodeOperation>(value);
+		print (mnp.getCommand());
+		print (mnp.getPosition());
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkPutAttributeOperationTest.cs	Sun Oct 23 13:35:21 2016 +0900
@@ -0,0 +1,22 @@
+using UnityEngine;
+using System.Collections;
+using MsgPack;
+using System;
+
+public class NetworkPutAttributeOperationTest : MonoBehaviour {
+
+	// Use this for initialization
+	void Start () {
+		byte[] value = System.Text.ASCIIEncoding.UTF8.GetBytes("test");
+		NetworkPutAttributeOperation op = new NetworkPutAttributeOperation("hoge", value);
+
+		ObjectPacker pack = new ObjectPacker();
+		// send this byte to server.
+		byte[] packValue = pack.Pack(op);
+
+		ObjectPacker unpack = new ObjectPacker();
+		NetworkPutAttributeOperation nOp = unpack.Unpack<NetworkPutAttributeOperation>(packValue);
+		print(System.Text.ASCIIEncoding.UTF8.GetString(nOp.getValue()));
+		print (nOp.getCommand());
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkTreeOperationLogTest.cs	Sun Oct 23 13:35:21 2016 +0900
@@ -0,0 +1,26 @@
+using UnityEngine;
+using System.Collections;
+using MsgPack;
+
+public class NetworkTreeOperationLogTest : MonoBehaviour {
+
+	// Use this for initialization
+	void Start () { // not work yet 10/23 13:33
+		NetworkAppendChildAtOperation op = new NetworkAppendChildAtOperation(1);
+		NetworkNodePath path = new NetworkNodePath();
+		NodePath npath = path.add(1).add(2);
+		NetworkTreeOperationLog log = new NetworkTreeOperationLog();
+		log.add(npath, op);
+		log.add(npath, op);
+		ObjectPacker pack = new ObjectPacker();
+		byte[] value = pack.Pack(log);
+
+		// unpackage
+		ObjectPacker unpack = new ObjectPacker();
+		NetworkTreeOperationLog mOp = unpack.Unpack<NetworkTreeOperationLog>(value);
+		foreach (var m in mOp) {
+			print(m.getNodePath().size());
+			print(m.getNodeOperation());
+		}
+	}
+}