package domain_test

import (
	"math"
	"testing"

	"gitea.dwysokinski.me/twhelp/corev3/internal/domain"
	"gitea.dwysokinski.me/twhelp/corev3/internal/domain/domaintest"
	"github.com/brianvoe/gofakeit/v6"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestNewPlayersSyncedEventPayload(t *testing.T) {
	t.Parallel()

	server := domaintest.NewServer(t)
	numPlayers := gofakeit.IntRange(0, math.MaxInt)

	payload, err := domain.NewPlayersSyncedEventPayload(
		server.Key(),
		server.URL(),
		server.VersionCode(),
		numPlayers,
	)
	require.NoError(t, err)
	assert.Equal(t, server.Key(), payload.ServerKey())
	assert.Equal(t, server.URL(), payload.ServerURL())
	assert.Equal(t, server.VersionCode(), payload.VersionCode())
	assert.Equal(t, numPlayers, payload.NumPlayers())
}
