1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-04 15:46:51 -05:00
OpenDiablo2/d2core/d2systems/timescale_test.go
2020-12-07 12:44:11 -08:00

42 lines
703 B
Go

package d2systems
import (
"testing"
"time"
"github.com/gravestench/akara"
)
func TestTimeScaleSystem_Init(t *testing.T) {
cfg := akara.NewWorldConfig()
cfg.With(NewTimeScaleSystem())
world := akara.NewWorld(cfg)
if len(world.Systems) != 1 {
t.Error("system not added to the world")
}
}
func TestTimeScaleSystem_Process(t *testing.T) {
cfg := akara.NewWorldConfig()
timescaleSystem := NewTimeScaleSystem()
cfg.With(timescaleSystem)
timescaleSystem.scale = 0.01
world := akara.NewWorld(cfg)
actual := time.Second
expected := time.Duration(timescaleSystem.scale) * actual
world.Update(actual)
if world.TimeDelta != expected {
t.Error("world time delta not scaled")
}
}