예제 #1
0
        public void Name_IsValid_WhenShorterThan18Characters()
        {
            var name = "abcdefghi";
            var runner = new Runner(name, "1/2");

            var error = runner.Error;

            error.Should().BeEmpty($"because {name} is less than 18 characters long");
        }
예제 #2
0
        public void Odds_IsInvalid_WhenContainsLetters()
        {
            var odds = "a/2";
            var runner = new Runner("abcde", odds);

            var error = runner.Error;

            error.Should().NotBeEmpty($"becuase {odds} contains a letter");
        }
예제 #3
0
        public void Name_IsInvalid_WhenLongerThan18Characters()
        {
            var name = "abcdefghijklmnopqrstuvwxyz";
            var runner = new Runner(name, "1/2");

            var error = runner.Error;

            error.Should().NotBeEmpty($"because {name} is longer than 18 characters");
        }
예제 #4
0
        public void Name_IsValid_When18CharactersLong()
        {
            var name = "abcdefghijklmnopqr";
            var runner = new Runner(name, "1/2");

            var error = runner.Error;

            error.Should().BeEmpty($"because {name} is 18 characters long");
        }
예제 #5
0
        public void Name_IsInvalid_WhenEmpty()
        {
            var name = String.Empty;
            var runner = new Runner(name, "1/2");

            var error = runner.Error;

            error.Should().NotBeEmpty($"because {name} is empty");
        }
예제 #6
0
        public void GetMargin_CalculatesMarginCorrectly()
        {
            var runner = new Runner("Name", "1/2");
            Decimal expectedMargin = 100 / (1m / 2m + 1);

            Decimal margin = runner.GetMargin();

            margin.Should().Be(expectedMargin);
        }
예제 #7
0
        public void Odds_IsInvalid_WhenContainsRealAtStart()
        {
            var odds = "1.5/2";
            var runner = new Runner("abcde", odds);

            var error = runner.Error;

            error.Should().NotBeEmpty($"because {odds} contains a real number");
        }
예제 #8
0
        public void Odds_IsValid_WhenInCorrectFormat()
        {
            var odds = "1/2";
            var runner = new Runner("abcde", odds);

            var error = runner.Error;

            error.Should().BeEmpty($"becuase {odds} is a valid odds string");
        }
예제 #9
0
        public void Odds_IsInvalid_WhenDoesNotContainForwardSlash()
        {
            var odds = "12";
            var runner = new Runner("abcde", odds);

            var error = runner.Error;

            error.Should().NotBeEmpty($"because {odds} does not contain a forward slash");
        }
예제 #10
0
        /// <summary>
        /// Adds a new <see cref="Runner"/> to <see cref="Runners"/>.
        /// </summary>
        public void AddRunner()
        {
            if (!_canAddRunner) return;
            Runner runner = new Runner(String.Format(Language.DefaultRunnerName, Runners.Count + 1), Language.DefaultRunnerOdds);
            runner.PropertyChanged += Runner_PropertyChanged;
            Runners.Add(runner);

            ReCalculateRaceMargin();
            _canAddRunner = Runners.Count < _maxRunnerCount;
            OnPropertyChanged(nameof(CanAddRunner));
        }