package handleMgr

import (
	"fmt"
	"reflect"
	"testing"
	"time"
)

// ---------------申请示例实例--------------
var (
	data = make(map[int]int, 0)
)

type testBll struct {
}

// TestAdd
// @description:测试添加
// parameter:
//		@receiver t:
//		@x:
//		@y:
// return:
//		@*ResponseObject:
func (t testBll) TestAdd(x, y int) *ResponseObject {
	responseObj := GetInitResponseObj()
	data[x] = y
	z := x + y

	print(x)

	responseObj.SetData(z)
	responseObj.SetResultStatus(-11111, "错误码")
	return responseObj
}

// See1
// @description:测试添加
// parameter:
//		@receiver t:
//		@x:
// return:
//		@*ResponseObject:
func (t testBll) See1(x int) *ResponseObject {
	responseObj := GetInitResponseObj()
	fmt.Print(x)
	return responseObj
}

// See2
// @description:测试添加
// parameter:
//		@receiver t:
//		@x:
// return:
//		@*ResponseObject:
func (t testBll) See2(x int) *ResponseObject {
	responseObj := GetInitResponseObj()
	time.Sleep(2000 * time.Millisecond)
	fmt.Print(x)
	return responseObj
}

func (t testBll) ReMove(x int) *ResponseObject {
	responseObj := GetInitResponseObj()
	delete(data, x)
	return responseObj
}

// ---------------测试方法--------------
func TestNew(t *testing.T) {

	var paramItem interface{}
	paramItem = 123
	paramFloat64, ok := paramItem.(int)
	if ok {
		x := reflect.ValueOf(int(paramFloat64))
		t.Log(x)
	}
	t.Log(paramFloat64)
	t.Log(ok)

	//t.Log("A")
	//RegisterNewModule("test", new(testBll), 10)

	//parameter := []interface{}{"1", 2}
	//x, y, mes := Done("test", "testBll", "TestAdd", parameter, false)
	//for key, item := range data {
	//	t.Log(key, item)
	//}

	//t.Log("B2")
	//parameter1 := []interface{}{2, 2}
	//x, y, mes = Done("test", "testBll", "TestAdd", parameter1, true)
	//for key, item := range data {
	//	t.Log(key, item)
	//}
	//t.Log(x)
	//t.Log(y)
	//t.Log(mes)
	//t.Log("B3")
	//
	//t.Log("C")
	//parameter2 := []interface{}{2}
	//Done("test", "testBll", "ReMove", parameter2, true)
	//for key, item := range data {
	//	t.Log(key, item)
	//}
	//t.Log("D")
	//
	//t.Log(time.Now().UnixMilli())
	//parameter3 := []interface{}{1}
	//Done("test", "testBll", "See2", parameter3, false)
	//t.Log(time.Now().UnixMilli())
	//parameter4 := []interface{}{2}
	//Done("test", "testBll", "See1", parameter4, true)
	//t.Log(time.Now().UnixMilli())
	//parameter5 := []interface{}{1}
	//Done("test", "testBll", "See1", parameter5, true)
	//t.Log(time.Now().UnixMilli())
	//
	//t.Log("E")
	//
	//t.Log(time.Now().UnixMilli())
	//for i := 0; i < 1000; i++ {
	//	Done("test", "testBll", "See1", parameter5, true)
	//}
	//t.Log(time.Now().UnixMilli())
	//t.Log("F")

	t.Error("G")
}
