1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-04 07:37:48 -05:00
OpenDiablo2/d2core/d2systems/timescale_test.go
gravestench c52c6648dd refactor of d2components, d2systems
Systems now place all of their component factories into a `Components`
member. This improves code readability and makes it clear when we are
dealing specifically with ecs components.

The concrete ComponentFactory instances now have `Add` and `Get`
methods (as opposed to `AddAlpha` or `GetAlpha`). This enforces naming
of component factories as to avoid collisions when embedded in a struct
with other components.

Also, the ComponentFactory interface is embedded directly into the
concrete component factory without a name.
2020-12-08 18:45:00 -08:00

44 lines
763 B
Go

package d2systems
import (
"testing"
"time"
"github.com/gravestench/akara"
)
func TestTimeScaleSystem_Init(t *testing.T) {
cfg := akara.NewWorldConfig()
cfg.With(&TimeScaleSystem{})
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 := &TimeScaleSystem{}
cfg.With(timescaleSystem)
timescaleSystem.scale = 0.01
world := akara.NewWorld(cfg)
actual := time.Second
expected := time.Duration(timescaleSystem.scale) * actual
if err := world.Update(actual); err != nil {
timescaleSystem.Error(err.Error())
}
if world.TimeDelta != expected {
t.Error("world time delta not scaled")
}
}