package com.craigvg.lichun_android.managers import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Test /** * Tests for BillingManager state and data classes. * Full purchase flow tests require an Android context and BillingClient mocking, * so here we test the data types and state semantics. */ class BillingManagerTest { @Test fun `ProductIds constants are correct`() { assertEquals("diamond1", ProductIds.DIAMOND_PACK_SMALL) assertEquals("diamond2", ProductIds.DIAMOND_PACK_LARGE) } @Test fun `PurchasableProduct holds correct values`() { val product = PurchasableProduct( productId = "diamond1", title = "Small Pack", description = "100 Diamonds", price = "$0.99", diamondReward = 100 ) assertEquals("diamond1", product.productId) assertEquals("Small Pack", product.title) assertEquals(100, product.diamondReward) assertEquals("$0.99", product.price) } @Test fun `PurchaseResult Success is singleton`() { val result: PurchaseResult = PurchaseResult.Success assertTrue(result is PurchaseResult.Success) } @Test fun `PurchaseResult Error holds message`() { val result = PurchaseResult.Error("Something went wrong") assertEquals("Something went wrong", result.message) } @Test fun `PurchaseResult Cancelled is singleton`() { val result: PurchaseResult = PurchaseResult.Cancelled assertTrue(result is PurchaseResult.Cancelled) } @Test fun `PurchaseResult Pending is singleton`() { val result: PurchaseResult = PurchaseResult.Pending assertTrue(result is PurchaseResult.Pending) } @Test fun `PurchaseResult types are distinct`() { val results = listOf( PurchaseResult.Success, PurchaseResult.Pending, PurchaseResult.Cancelled, PurchaseResult.Error("test") ) assertEquals(4, results.distinct().size) } }