import { TreeCount } from './tree-count.vo';

describe('TreeCount', () => {
  describe('create', () => {
    it('应该成功创建有效的树数量', () => {
      const treeCount = TreeCount.create(5);
      expect(treeCount.value).toBe(5);
    });

    it('应该拒绝0', () => {
      expect(() => TreeCount.create(0)).toThrow('认种数量必须是正整数');
    });

    it('应该拒绝负数', () => {
      expect(() => TreeCount.create(-1)).toThrow('认种数量必须是正整数');
    });

    it('应该拒绝小数', () => {
      expect(() => TreeCount.create(1.5)).toThrow('认种数量必须是正整数');
    });
  });

  describe('multiply', () => {
    it('应该正确计算乘法', () => {
      const treeCount = TreeCount.create(5);
      expect(treeCount.multiply(2199)).toBe(10995);
    });
  });

  describe('add', () => {
    it('应该正确相加', () => {
      const a = TreeCount.create(3);
      const b = TreeCount.create(5);
      const result = a.add(b);
      expect(result.value).toBe(8);
    });
  });

  describe('equals', () => {
    it('应该正确比较相等', () => {
      const a = TreeCount.create(5);
      const b = TreeCount.create(5);
      expect(a.equals(b)).toBe(true);
    });

    it('应该正确比较不相等', () => {
      const a = TreeCount.create(3);
      const b = TreeCount.create(5);
      expect(a.equals(b)).toBe(false);
    });
  });
});
