コード例 #1
0
        public void SolvePuzzle(string stream, int expectedScore)
        {
            var puzzleService = new PuzzleService();

            int score = puzzleService.Solve(stream);

            Assert.True(score == expectedScore);
        }
コード例 #2
0
 public void WhenPuzzleIsValid_ShouldReturnCorrectSolution()
 {
     mockLogger = new Mock <ILogger <PuzzleService> >();
     logger     = mockLogger.Object;
     sut        = new PuzzleService(logger);
     Int32[][] actualResult   = sut.GetSolvedSudoku6x6(testData.GetValidPuzzle0());
     Int32[][] expectedResult = testData.GetValidPuzzle0Solution();
     Assert.IsTrue(actualResult.AreEqual(expectedResult));
 }
コード例 #3
0
        public void WhenPuzzleIsInvalid_ShouldReturnNoSolution()
        {
            mockLogger = new Mock <ILogger <PuzzleService> >();
            logger     = mockLogger.Object;
            sut        = new PuzzleService(logger);
            var actualResult   = sut.GetSolvedSudoku6x6(testData.GetInvalidPuzzle());
            var expectedResult = (int[][])null;

            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #4
0
    public override void OnEnterStatus()
    {
        if (!isInit)
        {
            RhythmLibrary.Init();
            PuzzleService.Init();
        }

        OpenUI <CountDownWindow>();
    }
コード例 #5
0
 public List <string> GetWords()
 {
     try
     {
         PuzzleService service = new PuzzleService();
         return(service.GetWords(ConfigurationManagerHelper.GetKey("WordsPath")));
     }
     catch (Exception)
     {
         return(new List <string>());
     }
 }
コード例 #6
0
 public DTOSearchResult SearchWord([FromBody] DTOSearch word)
 {
     try
     {
         PuzzleService service = new PuzzleService();
         return(service.SearchWord(word));
     }
     catch (Exception)
     {
         return(new DTOSearchResult()
         {
             Breakdown = new List <LettersModel>(), Word = string.Empty
         });
     }
 }
コード例 #7
0
        public void InvalidStream_GarbageEndExpected(string stream)
        {
            var puzzleService = new PuzzleService();

            try
            {
                int score = puzzleService.Solve(stream);

                Assert.False(true, "No error was detected.");
            }
            catch (InvalidStreamException ex) when(ex.Message == InvalidStreamMessage.MissingGarbageEnding)
            {
                Assert.True(true);
            }
            catch (Exception ex)
            {
                Assert.False(true, String.Format("Incorrect exception thrown: {0}", ex.Message));
            }
        }
コード例 #8
0
    static void CreateAnswer()
    {
        PuzzleService.Reset();

        //去掉已出的所有句子
        for (int i = 0; i <= s_currentLine; i++)
        {
            PuzzleService.RemoveSentence(currentPoemData.m_content[i]);
        }

        PuzzleService.RemoveSentence(GetCurrentContent());

        s_correctIndex = GetRandomIndex(true);

        //正确答案
        m_questions[s_correctIndex] = GetCurrentContent();

        //错误答案
        m_questions[GetRandomIndex(false)] = PuzzleService.GetErrorAnswer(GetCurrentContent());
        m_questions[GetRandomIndex(false)] = PuzzleService.GetErrorAnswer(GetCurrentContent());
        m_questions[GetRandomIndex(false)] = PuzzleService.GetErrorAnswer(GetCurrentContent());

        if (LanguageManager.s_currentLanguage == SystemLanguage.ChineseTraditional)
        {
            m_questions[0] = ZhConverter.Convert(m_questions[0], ZhConverter.To.Traditional);
            m_questions[1] = ZhConverter.Convert(m_questions[1], ZhConverter.To.Traditional);
            m_questions[2] = ZhConverter.Convert(m_questions[2], ZhConverter.To.Traditional);
            m_questions[3] = ZhConverter.Convert(m_questions[3], ZhConverter.To.Traditional);
        }

        if (s_GameModel == GameModel.Arcade && HP == 0)
        {
            return;
        }

        GlobalEvent.DispatchEvent(GameEventEnum.QuestionChange);
    }
コード例 #9
0
ファイル: PuzzleTest.cs プロジェクト: dmacias/flashCardApp
 /// <summary>
 /// Note: This is a DI constructor, but the BS.TestSuite requires a no param constructor, 
 /// so services are being defined there 
 /// </summary>
 public PuzzleServiceTest(PuzzleService puzzleService)
 {
     this.puzzleService = puzzleService;
 }
コード例 #10
0
ファイル: PuzzleTest.cs プロジェクト: dmacias/flashCardApp
 public PuzzleServiceTest()
 {
     this.puzzleService = new PuzzleService();
 }