package com.ruoyi.app.omgpay;

import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

class OmgMerchantTradeNoGeneratorTest {
    @Test
    void generatesUniqueTwentyCharacterUppercaseIdentifiers() {
        OmgMerchantTradeNoGenerator generator = new OmgMerchantTradeNoGenerator();
        Set<String> values = new HashSet<>();
        for (int index = 0; index < 1_000; index++) {
            String value = generator.generate();
            assertEquals(20, value.length());
            assertTrue(value.startsWith("OMG"));
            assertTrue(value.matches("[A-Z0-9]{20}"));
            assertTrue(values.add(value));
        }
    }
}
