package net.shadowfacts.cacao.util.properties import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test /** * @author shadowfacts */ class ResettableLazyPropertyTests { class MyClass { var iteration = 1 val delegate = ResettableLazyProperty { "test ${iteration++}" } val prop by delegate } @Test fun testResets() { val obj = MyClass() assertEquals("test 1", obj.prop) obj.delegate.reset() assertEquals("test 2", obj.prop) assertEquals("test 2", obj.prop) } @Test fun testIsInitialized() { val obj = MyClass() assertFalse(obj.delegate.isInitialized) assertEquals("test 1", obj.prop) assertTrue(obj.delegate.isInitialized) obj.delegate.reset() assertFalse(obj.delegate.isInitialized) } }