Exemplo n.º 1
0
        public void Test2(int length, string expectedString)
        {
            //arrange
            List <int> states = new List <int>()
            {
                1, 2, 3, 4
            };
            int        startState  = 1;
            List <int> finalStates = new List <int>()
            {
                4
            };
            List <TransitionDTO> transitions = new List <TransitionDTO>()
            {
                new TransitionDTO(1, 'a', 2),
                new TransitionDTO(1, 'b', 3),
                new TransitionDTO(2, 'a', 4),
                new TransitionDTO(2, 'b', 2),
                new TransitionDTO(3, 'b', 4),
                new TransitionDTO(3, 'a', 3),
                new TransitionDTO(4, 'a', 4),
                new TransitionDTO(4, 'b', 4)
            };
            AutomatDTO automat = new AutomatDTO(states, transitions, startState, finalStates);

            //act
            string res = _worker.GetResult(automat, length);

            //assert
            Assert.AreEqual(res, expectedString);
        }
Exemplo n.º 2
0
        public string GetResult(AutomatDTO automat, int length)
        {
            this.automat = automat;
            this.length  = length;

            string res = FindResult();

            return(res);
        }
Exemplo n.º 3
0
        public Automat GetAutomatModel(AutomatDTO dto)
        {
            List <int>        states      = new List <int>(dto.States);
            int               startState  = dto.StartState;
            List <int>        finalStates = new List <int>(dto.FinalStates);
            List <Transition> transitions = GetTransitionModel(dto.Transitions);

            return(new Automat()
            {
                States = states,
                FinalStates = finalStates,
                StartState = startState,
                Transitions = transitions
            });
        }
Exemplo n.º 4
0
 public async Task <string> GetResultAsync(AutomatDTO automat, int length)
 {
     return(await Task.Run(() => GetResult(automat, length)));
 }