package digitaltwin_test

import (
	"testing"

	"github.com/fiskerinc/cloud-services/pkg/digitaltwin"

	"github.com/stretchr/testify/assert"
)

func TestDigitalTwinCache(t *testing.T) {
	vin1 := "11111111111111111"
	vin2 := "22222222222222222"
	prop1 := "prop1"
	prop2 := "prop2"

	cache := digitaltwin.NewDigitalTwinCache(3)

	exists := cache.Exists(vin1, prop1, 1)
	assert.Equal(t, false, exists)

	exists = cache.Exists(vin2, prop1, 1)
	assert.Equal(t, false, exists)

	exists = cache.Exists(vin1, prop1, 1)
	assert.Equal(t, true, exists)

	exists = cache.Exists(vin1, prop1, int64(2))
	assert.Equal(t, false, exists)

	exists = cache.Exists(vin1, prop2, true)
	assert.Equal(t, false, exists)

	exists = cache.Exists(vin2, prop2, true)
	assert.Equal(t, false, exists)

	exists = cache.Exists(vin2, prop1, true)
	assert.Equal(t, false, exists)

	exists = cache.Exists(vin1, prop1, int64(2))
	assert.Equal(t, false, exists)
}
