Пример #1
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);
        }
Пример #2
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"
         });
     };
 }
Пример #3
0
        public async Task Test_GetShowingMovies_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.GetShowingMovies();

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

            Assert.AreEqual("43c5a775-0075-4b2e-87e9-7e792ecfddf9", response.Data[0].Id);
            Assert.AreEqual("Showing 1", response.Data[0].Name);
            Assert.AreEqual(new DateTime(2019, 11, 30), response.Data[0].ReleaseDate);
            Assert.AreEqual((decimal)8.42, response.Data[0].Rating);
            Assert.AreEqual("Description showing 1", response.Data[0].Description);

            Assert.AreEqual("89dcbad0-a998-48b2-ab59-ec25adc95efd", response.Data[1].Id);
            Assert.AreEqual("Showing 2", response.Data[1].Name);
            Assert.AreEqual(new DateTime(2019, 11, 29), response.Data[1].ReleaseDate);
            Assert.AreEqual((decimal)7.82, response.Data[1].Rating);
            Assert.AreEqual("Description showing 2", response.Data[1].Description);
        }