public async Task GetAsyncReturnsSearchedElement()
        {
            // Arrange
            var mapper = new Mapper();
            var films  = new List <FilmData>
            {
                new FilmData {
                },
                new FilmData {
                }
            }.AsQueryable();

            var mockSet = new Mock <DbSet <FilmData> >();

            mockSet.As <IQueryable <FilmData> >().Setup(m => m.Provider).Returns(films.Provider);
            mockSet.As <IQueryable <FilmData> >().Setup(m => m.Expression).Returns(films.Expression);
            mockSet.As <IQueryable <FilmData> >().Setup(m => m.ElementType).Returns(films.ElementType);
            mockSet.As <IQueryable <FilmData> >().Setup(m => m.GetEnumerator()).Returns(films.GetEnumerator());

            var mockContext = new Mock <CinemaDbContext>();

            mockContext.Setup(c => c.FilmDatas).Returns(mockSet.Object);
            mockContext.Setup(c => c.FilmDatas.FindAsync(It.IsAny <string>())).
            Returns(new ValueTask <FilmData>((films.First())));

            var filmDataBusiness = new FilmDataBusiness(mockContext.Object);
            var searchedFilm     = films.First();

            // Act
            var resultFilm = await filmDataBusiness.GetAsync(searchedFilm.FilmId);

            // Assert
            Assert.AreEqual(searchedFilm, resultFilm, "Doesn't return the correct film data.");
        }
        public async Task GetAsyncReturnsSearchedElementMapped()
        {
            // Arrange
            var mapper = new Mapper();
            var films  = new List <FilmData>
            {
                new FilmData
                {
                    FilmId = "Film1",
                    Film   = new Film
                    {
                        FilmProjection = new List <FilmProjection>
                        {
                            new FilmProjection
                            {
                                Film = new Film {
                                    FilmData = new FilmData()
                                },
                                Cinema = new Cinema
                                {
                                    Manager         = new CinemaUser(),
                                    FilmProjections = new List <FilmProjection> {
                                        new FilmProjection()
                                    }
                                }
                            }
                        }
                    },
                    Genre = new List <GenreType>
                    {
                        new GenreType {
                            Genre = Genre.Action
                        }
                    },
                },
                new FilmData
                {
                    Film = new Film {
                        Rating = 3
                    }
                },
            }.AsQueryable();

            var mockSet = new Mock <DbSet <FilmData> >();

            mockSet.As <IQueryable <FilmData> >().Setup(m => m.Provider).Returns(films.Provider);
            mockSet.As <IQueryable <FilmData> >().Setup(m => m.Expression).Returns(films.Expression);
            mockSet.As <IQueryable <FilmData> >().Setup(m => m.ElementType).Returns(films.ElementType);
            mockSet.As <IQueryable <FilmData> >().Setup(m => m.GetEnumerator()).Returns(films.GetEnumerator());

            var mockContext = new Mock <CinemaDbContext>();

            mockContext.Setup(c => c.FilmDatas).Returns(mockSet.Object);
            mockContext.Setup(c => c.FilmDatas.FindAsync(It.IsAny <string>())).
            Returns(new ValueTask <FilmData>(films.First()));

            var filmDataBusiness = new FilmDataBusiness(mockContext.Object);
            var searchedFilm     = films.First();

            // Act
            var resultFilm = await filmDataBusiness.GetAsync(searchedFilm.FilmId, mapper.MapToFilmDataViewModel);

            // Assert
            Assert.AreEqual(searchedFilm.FilmId, resultFilm.Id, "Doesn't return the correct film data mapped.");
        }