<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using CGO.Domain;
using CGO.Web.Controllers;
using CGO.Web.Tests.EqualityComparers;
using CGO.Web.ViewModels;
using MvcContrib.TestHelper;
using NSubstitute;
using NUnit.Framework;
using Rhino.Mocks;

namespace CGO.Web.Tests.Controllers
{
    public class ConcertsControllerFacts
    {
        [TestFixture]
        public class WhenThereAreConcerts_IndexShould
        {
            [Test]
            public void DisplayTheIndexView()
            {
                var concertDetailsService = GetMockConcertDetailsService(new[] { new Concert(1, "Test Concert", DateTime.MinValue, "Venue") });
                var controller = new ConcertsController(concertDetailsService,
                                                        Substitute.For<IConcertsSeasonService>());

                var result = controller.Index();

                result.AssertViewRendered().ForView("Index").WithViewData<IEnumerable<Concert>>();
            }

            [Test]
            public void DisplayTheConcertsFromTheDatabase()
            {
                var expectedConcerts = new[] { new Concert(1, "Test Concert", DateTime.MinValue, "Venue") };
                var concertDetailsService = GetMockConcertDetailsService(expectedConcerts);
                var controller = new ConcertsController(concertDetailsService,
                                                        Substitute.For<IConcertsSeasonService>());

                var result = controller.Index() as ViewResult;
<commit_msg>Add tests for constructor dependencies.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using CGO.Domain;
using CGO.Web.Controllers;
using CGO.Web.Tests.EqualityComparers;
using CGO.Web.ViewModels;
using MvcContrib.TestHelper;
using NSubstitute;
using NUnit.Framework;
using Rhino.Mocks;

namespace CGO.Web.Tests.Controllers
{
    public class ConcertsControllerFacts
    {
        [TestFixture]
        public class ConstructorShould
        {
            [Test]
            public void ThrowAnArgumentNullExceptionIfTheConcertDetailsServiceIsNull()
            {
                Assert.That(() => new ConcertsController(null, Substitute.For<IConcertsSeasonService>()),
                            Throws.InstanceOf<ArgumentNullException>());
            } 
            
            [Test]
            public void ThrowAnArgumentNullExceptionIfTheConcertsSeasonServiceIsNull()
            {
                Assert.That(() => new ConcertsController(Substitute.For<IConcertDetailsService>(), null),
                            Throws.InstanceOf<ArgumentNullException>());
            }
        }

        [TestFixture]
        public class WhenThereAreConcerts_IndexShould
        {
            [Test]
            public void DisplayTheIndexView()
            {
                var concertDetailsService = GetMockConcertDetailsService(new[] { new Concert(1, "Test Concert", DateTime.MinValue, "Venue") });
                var controller = new ConcertsController(concertDetailsService,
                                                        Substitute.For<IConcertsSeasonService>());

                var result = controller.Index();

                result.AssertViewRendered().ForView("Index").WithViewData<IEnumerable<Concert>>();
            }

            [Test]
            public void DisplayTheConcertsFromTheDatabase()
            {
                var expectedConcerts = new[] { new Concert(1, "Test Concert", DateTime.MinValue, "Venue") };
                var concertDetailsService = GetMockConcertDetailsService(expectedConcerts);
                var controller = new ConcertsController(concertDetailsService,
                                                        Substitute.For<IConcertsSeasonService>());

                var result = controller.Index() as ViewResult;

{'fraction_non_alphanumeric': 0.08422391857506362, 'fraction_numerical': 0.0010178117048346056, 'mean_word_length': 2.152365677626303, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4150421', 'n_tokens_mistral': 997, 'n_tokens_neox': 948, 'n_words': 188}