コード例 #1
0
        public void StandingsShouldReturnLeaguesCollection()
        {
            // Arrange
            const string firstLeagueKey    = "premier-league";
            const string firstLeagueValue  = "PremierLeague";
            const string secondLeagueKey   = "la-league";
            const string secondLeagueValue = "La League";
            var          chartService      = new Mock <IChartService>();

            chartService.Setup(p => p.GetLeagues())
            .Returns(new Dictionary <string, string> {
                { firstLeagueKey, firstLeagueValue },
                { secondLeagueKey, secondLeagueValue }
            });

            var controller = new ChartController(chartService.Object, null);

            // Act
            var result = controller.Standings();

            // Assert
            result.Should().BeOfType <ViewResult>();

            var model = result.As <ViewResult>().Model;

            model.Should().BeOfType <Dictionary <string, string> >();

            var formModel = model.As <Dictionary <string, string> >();

            formModel.Should().ContainKey(firstLeagueKey);
            formModel.Should().ContainValue(firstLeagueValue);
            formModel.Should().ContainKey(secondLeagueKey);
            formModel.Should().ContainValue(secondLeagueValue);
        }