public void WhenMoovieIdExist_ShouldReturnTrue() { //Arrange var moovie = new Moovie() { Id = Guid.NewGuid(), Name = "", ReleaseDate = DateTime.Now.Brasilia(), Director = new Artist() { Name = "" }, Country = new Country() { Name = "" }, Genre = new Genre() { Name = "" }, Observations = "" }; var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(a => a.RepositoryBase.Get <Moovie>( It.IsAny <Expression <Func <Moovie, bool> > >(), It.IsAny <Func <IQueryable <Moovie>, IOrderedQueryable <Moovie> > >())) .Returns(new List <Moovie>() { moovie }.AsQueryable()); mockUnitOfWork .Setup(moq => moq.RepositoryBase.FirstOrDefault <Moovie>( It.IsAny <Expression <Func <Moovie, bool> > >(), It.IsAny <Func <IQueryable <Moovie>, IOrderedQueryable <Moovie> > >())) .Returns(moovie); var mockCountryService = new Mock <ICountryService>(); var mockGenreService = new Mock <IGenreService>(); var mockArtistService = new Mock <IArtistService>(); var service = new MoovieService(mockUnitOfWork.Object, mockArtistService.Object, mockCountryService.Object, mockGenreService.Object); //Act var result = service.GetBasicInfo(""); //Assert Assert.NotNull(result); Assert.True(result.Status); Assert.Equal("Filme localizado.", result.Message); Assert.NotNull(result.Object); }
public StringBuilder BuildSingleMooviePage(Moovie moovie) { var builder = new StringBuilder(); builder.Append("<html><body><h1>It works!</h1><ul>"); builder.AppendFormat("<li>Id: {0}, Name: {1}, Year: {2}, Genre: {3}</li>", moovie.Id, moovie.Name, moovie.Year, moovie.Genre); builder.Append(@"</ul></body></html>"); return(builder); }
static void Main(string[] args) { int numberOfMoovies = int.Parse(Console.ReadLine()); List <Moovie> movies = new List <Moovie>(); for (int i = 0; i < numberOfMoovies; i++) { string moovieName = Console.ReadLine(); double movieRating = double.Parse(Console.ReadLine()); movies.Add(new Moovie(moovieName, movieRating)); } Moovie moovieTopRating = movies.LastOrDefault(x => x.Rating == movies.Max(m => m.Rating)); Moovie moovieBottomRating = movies.LastOrDefault(x => x.Rating == movies.Min(m => m.Rating)); double moovieAverageRating = movies.Average(x => x.Rating); Console.WriteLine($"{moovieTopRating.Name} is with highest rating: {moovieTopRating.Rating:f1}"); Console.WriteLine($"{moovieBottomRating.Name} is with lowest rating: {moovieBottomRating.Rating:f1}"); Console.WriteLine($"Average rating: {moovieAverageRating:f1}"); }
public Result Create(CreateMoovieModel moovie) { var moovieId = GetId(moovie.Name); if (moovieId != null && moovieId != Guid.Empty) { return new Result() { Status = false, Message = "Filme já existente." } } ; var directorId = _artistService.Get(moovie.DirectorName, Data.Enums.Artist.Type.Director); if (directorId == null || directorId == Guid.Empty) { return new Result() { Status = false, Message = "Diretor não encontrado." } } ; var countryId = _countryService.Get(moovie.CountryName); if (countryId == null || countryId == Guid.Empty) { return new Result() { Status = false, Message = "Nacionalidade não encontrada." } } ; var genreId = _genreService.Get(moovie.GenreName); if (genreId == null || genreId == Guid.Empty) { return new Result() { Status = false, Message = "Gênero de filme não encontrado." } } ; var newMoovieDatabaseModel = new Moovie() { Id = Guid.NewGuid(), Name = moovie.Name, ReleaseDate = moovie.ReleaseDate, DirectorId = (Guid)directorId, CountryId = (Guid)countryId, GenreId = (Guid)genreId, Observations = moovie.Observations }; _unitOfWork.RepositoryBase.Add(newMoovieDatabaseModel); _unitOfWork.Commit(); return(new Result() { Status = true, Message = "Filme adicionado com sucesso!", Object = moovie }); }