Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • VisualStudio에 유닛테스트 프로젝트활용
  • 분산환경 메시지 Test를 위해 AKKA Test Toolkit사용
  • 간단하게 사용자 정의 클래스 생성하여 학습 코드 집합


여기서는, 마지막 방법을 사용하여 심플한 클래스작성하여 여러가지 AKKA의 기능을 테스트 하겠습니다.

...

Code Block
languagec#
themeEmacs
titleActor를 학습하고 테스트하는 Class
linenumberstrue
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외에 , RemoteActor RemoteActorTest , ClusterActor등 ClusterActorTest 등 학습 목적에따라 Class로 분리예정이며

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


Code Block
languagec#
themeEmacs
titleAPP Main 진입점
linenumberstrue
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.RunRunAll();

                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;
        }
    }
}

...