Example #1
0
        public void can_parse_correctly_formatted_input(string input, int[] expectedPeriodsBeforeMilliseconds, MetronomeTickType[] expectedTickTypes)
        {
            Assert.Equal(expectedPeriodsBeforeMilliseconds.Length, expectedTickTypes.Length);

            var result = MetronomeActionParser
                         .GetParser(
                new AudioServiceMock(MockBehavior.Loose),
                new DelayServiceMock(MockBehavior.Loose))
                         .Parse(input);

            Assert.NotNull(result);
            Assert.Equal(expectedPeriodsBeforeMilliseconds.Length, result.Ticks.Count);

            Assert.True(
                expectedPeriodsBeforeMilliseconds
                .Select(x => TimeSpan.FromMilliseconds(x))
                .SequenceEqual(
                    result
                    .Ticks
                    .Select(x => x.PeriodBefore)));
            Assert.True(
                expectedTickTypes
                .SequenceEqual(
                    result
                    .Ticks
                    .Select(x => x.Type)));
        }
Example #2
0
        public void cannot_parse_incorrectly_formatted_input(string input)
        {
            var result = MetronomeActionParser
                         .GetParser(
                new AudioServiceMock(MockBehavior.Loose),
                new DelayServiceMock(MockBehavior.Loose))(new Input(input));

            Assert.False(result.WasSuccessful && result.Remainder.AtEnd);
        }
Example #3
0
 public void get_parser_throws_if_logger_service_is_null()
 {
     Assert.Throws <ArgumentNullException>(() => MetronomeActionParser.GetParser(new AudioServiceMock(), new DelayServiceMock(), null));
 }