예제 #1
0
        /// <summary>
        /// Executes the specified option.
        /// </summary>
        /// <param name="idExecution">The option.</param>
        public void Execute(int idExecution)
        {
            var planets          = PlanetStorage.GetByCriteria(p => p.Galaxy.Id == GalaxyService.DefaultGalaxyId());
            var predictionResult = GalaxyService.PredictWeather(planets, day: idExecution);
            var weatherHistory   = new WeatherHistory {
                Day = idExecution, Weather = predictionResult.WeatherCondition, TrianglePerimeter = predictionResult.TrianglePerimeter
            };

            WeatherHistoryStorage.Save(weatherHistory);
        }
예제 #2
0
        public async Task Test_GetMovieDetails_Success()
        {
            // arrange
            var responseData = new ShowAndComingModel
            {
                MovieCommingSoon = new List <GalaxyMovie>
                {
                    new GalaxyMovie
                    {
                        Id          = new Guid("555f43a1-6b61-4dcd-8ef8-43e61e2b9df1"),
                        Name        = "Coming 1",
                        Startdate   = new DateTime(2019, 11, 29),
                        Point       = (decimal)7.82,
                        Description = "Description coming 1"
                    }
                },
                MovieShowing = new List <GalaxyMovie>
                {
                    new GalaxyMovie
                    {
                        Id          = new Guid("43c5a775-0075-4b2e-87e9-7e792ecfddf9"),
                        Name        = "Showing 1",
                        Startdate   = new DateTime(2019, 11, 30),
                        Point       = (decimal)8.42,
                        Description = "Description showing 1"
                    },
                    new GalaxyMovie
                    {
                        Id          = new Guid("89dcbad0-a998-48b2-ab59-ec25adc95efd"),
                        Name        = "Showing 2",
                        Startdate   = new DateTime(2019, 11, 29),
                        Point       = (decimal)7.82,
                        Description = "Description showing 2"
                    }
                }
            };

            _requesterMock
            .Setup(x => x.Get <ShowAndComingModel>(It.IsAny <string>()))
            .ReturnsAsync(responseData);

            // action
            var galaxyService = new GalaxyService(_requesterMock.Object);
            var response      = await galaxyService.GetMovieDetails("89dcbad0-a998-48b2-ab59-ec25adc95efd");

            // assert
            Assert.IsTrue(response.Success);
            Assert.AreEqual("89dcbad0-a998-48b2-ab59-ec25adc95efd", response.Data.Id);
            Assert.AreEqual("Showing 2", response.Data.Name);
            Assert.AreEqual(new DateTime(2019, 11, 29), response.Data.ReleaseDate);
            Assert.AreEqual((decimal)7.82, response.Data.Rating);
            Assert.AreEqual("Description showing 2", response.Data.Description);
        }
예제 #3
0
        public async Task Test_GetShowingMovies_Failed()
        {
            // arrange
            _requesterMock
            .Setup(x => x.Get <ShowAndComingModel>(It.IsAny <string>()))
            .ThrowsAsync(new Exception("Request failed"));

            // action
            var galaxyService = new GalaxyService(_requesterMock.Object);
            var response      = await galaxyService.GetShowingMovies();

            // assert
            Assert.IsFalse(response.Success);
            Assert.IsNull(response.Data);
            Assert.AreEqual("Request failed", response.Message);
        }
예제 #4
0
        public async Task Test_GetMovieSessions_Failed()
        {
            // arrange
            _requesterMock
            .Setup(x => x.Get <List <GalaxyMovieSession> >(It.IsAny <string>()))
            .ThrowsAsync(new Exception("Request failed"));

            // action
            var galaxyService = new GalaxyService(_requesterMock.Object);
            var response      = await galaxyService.GetMovieSessions("89dcbad0-a998-48b2-ab59-ec25adc95efd");

            // assert
            Assert.IsFalse(response.Success);
            Assert.IsNull(response.Data);
            Assert.AreEqual("Request failed", response.Message);
        }
예제 #5
0
 /// <summary>
 /// Get movie details (default domain)
 /// </summary>
 /// <param name="type">Type of vender (ex: Galaxy, Lotte, ...)</param>
 /// <param name="movieId">Moive's id, type string: different id's type between vendors (string is the best type here)</param>
 /// <returns>Detail of movie with status and message</returns>
 public async Task <MovieResult> GetMovieDetails(VendorType type, string movieId)
 {
     if (type == VendorType.GalaxyCinema)
     {
         var galaxyService = new GalaxyService(_requester);
         return(await galaxyService.GetMovieDetails(movieId));
     }
     else if (type == VendorType.Lotteria)
     {
         var lotteService = new LotteService(_requester);
         return(await lotteService.GetMovieDetails(movieId));
     }
     else
     {
         return(new MovieResult
         {
             Success = false,
             Message = "Not implemented"
         });
     };
 }
예제 #6
0
 /// <summary>
 /// Get current showing movies (new domain)
 /// </summary>
 /// <param name="type">Type of vender (ex: Galaxy, Lotte, ...)</param>
 /// <returns>List of current show movie model with status and message</returns>
 public async Task <MovieListResult> GetShowingMovies(VendorType type, string domain)
 {
     if (type == VendorType.GalaxyCinema)
     {
         var galaxyService = new GalaxyService(domain, _requester);
         return(await galaxyService.GetShowingMovies());
     }
     else if (type == VendorType.Lotteria)
     {
         var lotteService = new LotteService(domain, _requester);
         return(await lotteService.GetShowingMovies());
     }
     else
     {
         return(new MovieListResult
         {
             Success = false,
             Message = "Not implemented"
         });
     };
 }
예제 #7
0
        public void Test_SplitSessions()
        {
            // arrange
            var data = new List <GalaxyMovieSession>
            {
                new GalaxyMovieSession
                {
                    Address = "Address 1",
                    Dates   = new List <GalaxySessionDate>
                    {
                        new GalaxySessionDate
                        {
                            Bundles = new List <GalaxySessionDateBundle>
                            {
                                new GalaxySessionDateBundle
                                {
                                    Sessions = new List <BundleSession>
                                    {
                                        new BundleSession
                                        {
                                            ShowDate = "20191129",
                                            ShowTime = "1215"
                                        },
                                        new BundleSession
                                        {
                                            ShowDate = "20191130",
                                            ShowTime = "2030"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                new GalaxyMovieSession
                {
                    Address = "Address 2",
                    Dates   = new List <GalaxySessionDate>
                    {
                        new GalaxySessionDate
                        {
                            Bundles = new List <GalaxySessionDateBundle>
                            {
                                new GalaxySessionDateBundle
                                {
                                    Sessions = new List <BundleSession>
                                    {
                                        new BundleSession
                                        {
                                            ShowDate = "20191129",
                                            ShowTime = "1745"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            // action
            var galaxyService = new GalaxyService(_requesterMock.Object);
            var sessions      = galaxyService.SplitSessions(data);

            // assert
            Assert.AreEqual(3, sessions.Count);

            Assert.AreEqual("Address 1", sessions[0].Address);
            Assert.AreEqual("20191129", sessions[0].ShowDate);
            Assert.AreEqual("1215", sessions[0].ShowTime);

            Assert.AreEqual("Address 1", sessions[1].Address);
            Assert.AreEqual("20191130", sessions[1].ShowDate);
            Assert.AreEqual("2030", sessions[1].ShowTime);

            Assert.AreEqual("Address 2", sessions[2].Address);
            Assert.AreEqual("20191129", sessions[2].ShowDate);
            Assert.AreEqual("1745", sessions[2].ShowTime);
        }
예제 #8
0
        public async Task Test_GetMovieSessions_Success()
        {
            // arrange
            var responseData = new List <GalaxyMovieSession>
            {
                new GalaxyMovieSession
                {
                    Address = "Address 1",
                    Dates   = new List <GalaxySessionDate>
                    {
                        new GalaxySessionDate
                        {
                            Bundles = new List <GalaxySessionDateBundle>
                            {
                                new GalaxySessionDateBundle
                                {
                                    Sessions = new List <BundleSession>
                                    {
                                        new BundleSession
                                        {
                                            ShowDate = "20191129",
                                            ShowTime = "1215"
                                        },
                                        new BundleSession
                                        {
                                            ShowDate = "20191130",
                                            ShowTime = "2030"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                new GalaxyMovieSession
                {
                    Address = "Address 2",
                    Dates   = new List <GalaxySessionDate>
                    {
                        new GalaxySessionDate
                        {
                            Bundles = new List <GalaxySessionDateBundle>
                            {
                                new GalaxySessionDateBundle
                                {
                                    Sessions = new List <BundleSession>
                                    {
                                        new BundleSession
                                        {
                                            ShowDate = "20191129",
                                            ShowTime = "1745"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            _requesterMock
            .Setup(x => x.Get <List <GalaxyMovieSession> >(It.IsAny <string>()))
            .ReturnsAsync(responseData);

            // action
            var galaxyService = new GalaxyService(_requesterMock.Object);
            var response      = await galaxyService.GetMovieSessions("89dcbad0-a998-48b2-ab59-ec25adc95efd");

            // assert
            Assert.IsTrue(response.Success);
            Assert.AreEqual(3, response.Data.Count);

            Assert.AreEqual("89dcbad0-a998-48b2-ab59-ec25adc95efd", response.Data[0].MovieId);
            Assert.AreEqual("Address 1", response.Data[0].Location);
            Assert.AreEqual("20191129", response.Data[0].ShowDate);
            Assert.AreEqual("1215", response.Data[0].ShowTime);

            Assert.AreEqual("89dcbad0-a998-48b2-ab59-ec25adc95efd", response.Data[1].MovieId);
            Assert.AreEqual("Address 1", response.Data[1].Location);
            Assert.AreEqual("20191130", response.Data[1].ShowDate);
            Assert.AreEqual("2030", response.Data[1].ShowTime);

            Assert.AreEqual("89dcbad0-a998-48b2-ab59-ec25adc95efd", response.Data[2].MovieId);
            Assert.AreEqual("Address 2", response.Data[2].Location);
            Assert.AreEqual("20191129", response.Data[2].ShowDate);
            Assert.AreEqual("1745", response.Data[2].ShowTime);
        }
예제 #9
0
 public GalaxyController(GalaxyService service)
 {
     _service = service;
 }