Esempio n. 1
0
        public void ReturnAllBand_WithTheGivenLetter()
        {
            const string letter = "A";

            var contextMock        = new Mock <IMusicLibraryContext>();
            var contextBaseMock    = new Mock <IMusicLibraryBaseContext>();
            var countryServiceMock = new Mock <ICountryService>();
            var genreServiceMock   = new Mock <IGenreService>();
            var userServiceMock    = new Mock <IUserService>();
            var bandFactoryMock    = new Mock <IBandFactory>();
            var bands = GetBands();

            var bandsSetMock   = QueryableDbSetMock.GetQueryableMockDbSet(bands);
            var expectedResult = bands.Where(x => x.BandName.Substring(0, 1) == letter).ToList();

            contextMock.Setup(x => x.Bands).Returns(bandsSetMock);

            var bandService = new BandService(
                contextMock.Object,
                contextBaseMock.Object,
                countryServiceMock.Object,
                genreServiceMock.Object,
                userServiceMock.Object,
                bandFactoryMock.Object);

            var actualResult = bandService.GetBands(letter);

            CollectionAssert.AreEquivalent(actualResult.ToList(), expectedResult);
        }
Esempio n. 2
0
        public void DoesNotReturnABand_WithDifferentStartingLetter()
        {
            const string letter = "A";

            var contextMock        = new Mock <IMusicLibraryContext>();
            var contextBaseMock    = new Mock <IMusicLibraryBaseContext>();
            var countryServiceMock = new Mock <ICountryService>();
            var genreServiceMock   = new Mock <IGenreService>();
            var userServiceMock    = new Mock <IUserService>();
            var bandFactoryMock    = new Mock <IBandFactory>();
            var bands = GetBands();

            var expectedResult = bands.AsQueryable();
            var bandsSetMock   = QueryableDbSetMock.GetQueryableMockDbSet(bands);

            contextMock.Setup(x => x.Bands).Returns(bandsSetMock);

            var bandService = new BandService(
                contextMock.Object,
                contextBaseMock.Object,
                countryServiceMock.Object,
                genreServiceMock.Object,
                userServiceMock.Object,
                bandFactoryMock.Object);

            var actualResult = bandService.GetBands(letter);

            CollectionAssert.DoesNotContain(actualResult.ToList(), expectedResult.Where(x => x.BandName == "Behemoth"));
        }
Esempio n. 3
0
        public async Task <IActionResult> Index()
        {
            var bands = await _service.GetBands();

            return(View(bands));
        }