Exemplo n.º 1
0
        public void AbleToParse_ParseFirstHidatoScore()
        {
            string text = "Hidato: 26360 (2100, 10000, 1080, 2x) 2:00";
            text += "\r\nHidato: 1 (2, 3, 4, 5x) 6:00";

            var parser = new HidatoScoreParser();
            var output = parser.Parse(text);

            var expectedValue = new HidatoScore
                                {
                                    TotalScore = 26360,
                                    TileScore = 2100,
                                    PerfectBonus = 10000,
                                    TimeBonus = 1080,
                                    Multiplier = 2,
                                    TimeInSeconds = 120,
                                    Date = DateTime.UtcNow.Date
                                };

            Assert.True(output.IsSuccess);
            Assert.Empty(output.ErrorMessages);
            Assert.Empty(output.Exceptions);

            Assert.Equal(expectedValue.TotalScore, output.Value.TotalScore);
            Assert.Equal(expectedValue.TileScore, output.Value.TileScore);
            Assert.Equal(expectedValue.PerfectBonus, output.Value.PerfectBonus);
            Assert.Equal(expectedValue.TimeBonus, output.Value.TimeBonus);
            Assert.Equal(expectedValue.Multiplier, output.Value.Multiplier);
            Assert.Equal(expectedValue.TimeInSeconds, output.Value.TimeInSeconds);
            Assert.Equal(expectedValue.Date, output.Value.Date);
        }
Exemplo n.º 2
0
        public void AbleToParse_LooseHidatoScoreFormat_OnlySpaces()
        {
            string text = "Hidato: 26360 2100 10000 1080 2x 2:00";

            var parser = new HidatoScoreParser();
            var output = parser.Parse(text);

            var expectedValue = new HidatoScore
                                {
                                    TotalScore = 26360,
                                    TileScore = 2100,
                                    PerfectBonus = 10000,
                                    TimeBonus = 1080,
                                    Multiplier = 2,
                                    TimeInSeconds = 120,
                                    Date = DateTime.UtcNow.Date
                                };

            Assert.True(output.IsSuccess);
            Assert.Empty(output.ErrorMessages);
            Assert.Empty(output.Exceptions);

            Assert.Equal(expectedValue.TotalScore, output.Value.TotalScore);
            Assert.Equal(expectedValue.TileScore, output.Value.TileScore);
            Assert.Equal(expectedValue.PerfectBonus, output.Value.PerfectBonus);
            Assert.Equal(expectedValue.TimeBonus, output.Value.TimeBonus);
            Assert.Equal(expectedValue.Multiplier, output.Value.Multiplier);
            Assert.Equal(expectedValue.TimeInSeconds, output.Value.TimeInSeconds);
            Assert.Equal(expectedValue.Date, output.Value.Date);
        }
Exemplo n.º 3
0
        public void UnableToParse_EmptyText()
        {
            string text = string.Empty;

            var parser = new HidatoScoreParser();
            var output = parser.Parse(text);

            Assert.False(output.IsSuccess);
            Assert.Contains("Unable to parse the Hidato score", output.ErrorMessages);
        }
Exemplo n.º 4
0
        public void UnableToParse_NoLineBeginsWithHidato()
        {
            string text = "This is just a normal sentence.";

            var parser = new HidatoScoreParser();
            var output = parser.Parse(text);

            Assert.False(output.IsSuccess);
            Assert.Contains("Unable to parse the Hidato score", output.ErrorMessages);
        }
Exemplo n.º 5
0
        public void AbleToParse_StrictHidatoScoreFormatWithDate()
        {
            string text = "Date: 1/14/1985";
            text += "\r\nHidato: 26360 (2100, 10000, 1080, 2x) 2:00";

            var parser = new HidatoScoreParser();
            var output = parser.Parse(text);

            var expectedValue = new HidatoScore
                                {
                                    TotalScore = 26360,
                                    TileScore = 2100,
                                    PerfectBonus = 10000,
                                    TimeBonus = 1080,
                                    Multiplier = 2,
                                    TimeInSeconds = 120,
                                    Date = new DateTime(1985, 1, 14)
                                };

            Assert.True(output.IsSuccess);
            Assert.Empty(output.ErrorMessages);
            Assert.Empty(output.Exceptions);

            Assert.Equal(expectedValue.TotalScore, output.Value.TotalScore);
            Assert.Equal(expectedValue.TileScore, output.Value.TileScore);
            Assert.Equal(expectedValue.PerfectBonus, output.Value.PerfectBonus);
            Assert.Equal(expectedValue.TimeBonus, output.Value.TimeBonus);
            Assert.Equal(expectedValue.Multiplier, output.Value.Multiplier);
            Assert.Equal(expectedValue.TimeInSeconds, output.Value.TimeInSeconds);
            Assert.Equal(expectedValue.Date, output.Value.Date);
        }