최초 프로젝트 셋팅


코드 테스트환경 구축

코드 테스트를 하기위해서 다음과 같은 방법이 있습니다.


여기서는, 심플한 클래스작성하여 여러가지 AKKA의 학습목적에 맞게 기능 테스트 하겠습니다.

사용자 정의 테스트 클래스 작성

using Akka.Actor;

namespace ServiceA.STUDY
{
    public class ActorTest  //Actor 기본 테스트를 위해서~~
    {
        protected ActorSystem actorSystem;

        public ActorTest(ActorSystem system)  //메인 APP에서 생성한 AKKA System만 참조하면 됩니다.
        {
            actorSystem = system;
        }

        protected void SomeTest1()
        {

        }

        public void RunAll()
        {
            SomeTest1(); //SubTest

        }
    }
}


 이렇게 하는 이유는 단지, 기존 어플리케이션 코드에서 학습 진행한 코드를 섹션별로 분리목적으로 큰 의도는 없습니다.

위와 같은 템플릿은 ActorTest외에 , RemoteActorTest , ClusterActorTest 등 학습 목적에따라 Class로 분리예정이며

생성패턴이 유사하니 추가로 언급하지 않겠습니다.


using Akka.Actor;

using ServiceA.STUDY;

namespace ServiceA
{
    class Program
    {
        static void Main(string[] args)
        {
            ConsoleKeyInfo cki;
            Console.CancelKeyPress += new ConsoleCancelEventHandler(myHandler);
            using (ActorSystem system = ActorSystem.Create("ServiceA"))
            {
                //Actor의 시스템 준비 완료

                //ActorTest -ActorTest코드는 아래 두줄외에 더이상 추가가 안됩니다.
                ActorTest actorTest = new ActorTest(system);
                actorTest.RunAll();

                while (true)
                {
                    // 메인 어플리케이션 종료방지를 위한코드 ( ctrl+x 종료 )
                    cki = Console.ReadKey(true);
                    if (cki.Key == ConsoleKey.X) break;
                }
            }
        }

        protected static void myHandler(object sender, ConsoleCancelEventArgs args)
        {
            args.Cancel = true;
        }
    }
}