package com.ruoyi.web.modules.account.service;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import com.ruoyi.web.modules.account.dto.MemberCreateDTO;
import com.ruoyi.web.modules.account.support.MemberRegistrationSupport;
import com.ruoyi.web.modules.account.service.impl.MemberServiceImpl;

@ExtendWith(MockitoExtension.class)
class MemberServiceImplCreateTest
{
    @Mock
    private MemberRegistrationSupport memberRegistrationSupport;

    @InjectMocks
    private MemberServiceImpl memberService;

    @Test
    void createMember_delegatesToSupport()
    {
        MemberCreateDTO dto = new MemberCreateDTO();
        dto.setMobile("17700001111");
        dto.setPassword("Pass1234");
        when(memberRegistrationSupport.createMember(any(), eq("admin"))).thenReturn(100L);

        Long memberId = memberService.createMember(dto, "admin");

        assertEquals(100L, memberId);
        verify(memberRegistrationSupport).createMember(dto, "admin");
    }
}
