package com.red.circle.wallet.infra.database.mongo.service.bank.impl;

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

import org.bson.Document;
import org.junit.jupiter.api.Test;

class UserBankBalanceServiceImplTest {

  @Test
  void getLongValueAcceptsIntegerBalance() {
    Document document = new Document("balance", 0);

    assertEquals(0L, UserBankBalanceServiceImpl.getLongValue(document, "balance"));
  }

  @Test
  void getLongValueAcceptsLongBalance() {
    Document document = new Document("balance", 123L);

    assertEquals(123L, UserBankBalanceServiceImpl.getLongValue(document, "balance"));
  }

  @Test
  void getLongValueDefaultsMissingBalanceToZero() {
    Document document = new Document();

    assertEquals(0L, UserBankBalanceServiceImpl.getLongValue(document, "balance"));
  }
}
