func TestCore_Spaces(t *testing.T) { core := New() // Space Setup Spc1 := &TestSpace{name: "Spc1"} Spc2 := &TestSpace{name: "Spc2"} core.RegisterSpace(Spc1) core.RegisterSpace(Spc2) // Testing core.StartUp() actOut = nil expOut := []string{ "Spc1 Init()", "Spc2 Init()", } core.StartUp(nil) test.AssertEQ(t, len(expOut), len(actOut), "Length of actOut and expOut aren't equal.") for i, s := range actOut { test.ExpectEQ(t, expOut[i], s, fmt.Sprintf("With test %d: Initialization order was wrong.", i)) } // Testing Core.Run() actOut = nil expOut = []string{ "Spc1 Update()", "Spc2 Update()", } core.State = Stopped core.Run() test.AssertEQ(t, len(expOut), len(actOut), "Length of actOut and expOut aren't equal.") for i, s := range actOut { test.ExpectEQ(t, expOut[i], s, fmt.Sprintf("With test %d: Frame Update order was wrong.", i)) } // Testing core.ShutDown() actOut = nil expOut = []string{ "Spc2 DeInit()", "Spc1 DeInit()", } core.ShutDown() test.AssertEQ(t, len(expOut), len(actOut), "Length of actOut and expOut aren't equal.") for i, s := range actOut { test.ExpectEQ(t, expOut[i], s, fmt.Sprintf("With test %d: DeInitialization order was wrong.", i)) } }
func TestCore_Managers(t *testing.T) { core := New() // Test Setup Mgr1 := &TestManager{name: "Mgr1", comp: "TestMgr1InitComponent"} Mgr2 := &TestManager{name: "Mgr2", comp: "TestMgr2InitComponent"} CoreFactoryFunc = func(name string) interface{} { var comp interface{} switch name { default: support.LogFatal("unknown component: %s", name) case "TestMgr1InitComponent": comp = &TestMgr1InitComponent{} case "TestMgr2InitComponent": comp = &TestMgr2InitComponent{} } return comp } core.RegisterManager(Mgr1) core.RegisterManager(Mgr2) cfg := LoadConfig("C:/Users/jmorgan/Sandbox/golang/rsrc/test/json/objects/kernel/TestCore.jrm") // Testing Core.StartUp() actOut = nil expOut := []string{ "Mgr1 StartUp()", "Mgr1 got config", "Mgr2 StartUp()", "Mgr2 got config", } core.StartUp(cfg) test.AssertEQ(t, len(expOut), len(actOut), "Length of actOut and expOut aren't equal. "+fmt.Sprintf("\n\t\tactOut: %v", actOut)) for i, s := range actOut { test.ExpectEQ(t, expOut[i], s, fmt.Sprintf("With test %d: Initialization order was wrong.", i)) } // Testing Core.Run() actOut = nil expOut = []string{ "Mgr1 BeginFrame()", "Mgr2 BeginFrame()", "Mgr2 EndFrame()", "Mgr1 EndFrame()", } core.State = Stopped core.Run() test.AssertEQ(t, len(expOut), len(actOut), "Length of actOut and expOut aren't equal.") for i, s := range actOut { test.ExpectEQ(t, expOut[i], s, fmt.Sprintf("With test %d: Frame Update order was wrong.", i)) } // Testing Core.ShutDown() actOut = nil expOut = []string{ "Mgr2 ShutDown()", "Mgr1 ShutDown()", } core.ShutDown() test.AssertEQ(t, len(expOut), len(actOut), "Length of actOut and expOut aren't equal.") for i, s := range actOut { test.ExpectEQ(t, expOut[i], s, fmt.Sprintf("With test %d: DeInitialization order was wrong.", i)) } }