public async Task GetSessionOfMovie_Should_Return_OK() { // Arrange dynamic session1 = new JObject(); session1.id = "0e67de8d-8190-45e2-b2aa-aa30468d867f"; session1.name = "Galaxy Quang Trung"; session1.phone = "1900 2224"; session1.address = "Lầu 3, CoopMart Foodcosa số 304A, Quang Trung, P.11, Q. Gò Vấp, Tp.HCM"; dynamic session2 = new JObject(); session1.id = "0f95ca57-3707-4e69-bf01-c15993afd3ea"; session1.name = "Galaxy Bến Tre"; session1.phone = "1900 2224"; session1.address = "Lầu 1, Sense City 26A Trần Quốc Tuấn, Phường 4, TP. Bến Tre"; dynamic movies = new JArray(session1, session2); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(movies.ToString(), System.Text.Encoding.UTF8, "application/json") }; _httpHandlerMock.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response)); var service = new GalaxyVendorService(_httpHandlerMock.Object); // Action var result = await service.GetSessionOfMovie("123"); // Assert Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); }
public async Task GetNowShowingMovies_Should_Return_OK_Case_Empty() { // Arrange dynamic movieShowing = new JObject(); movieShowing.id = "0e67de8d-8190-45e2-b2aa-aa30468d867f"; movieShowing.name = "Doremon"; movieShowing.age = "18"; dynamic movies = new JObject(); movies.notExist = new JArray(movieShowing); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(movies.ToString(), System.Text.Encoding.UTF8, "application/json") }; _httpHandlerMock.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response)); var service = new GalaxyVendorService(_httpHandlerMock.Object); // Action var result = await service.GetNowShowingMovies(); // Assert Assert.IsNotNull(result); Assert.AreEqual(0, result.Count); }
public void GetMovieDetail_Should_Throw_NotSupportException() { // Arrange var service = new GalaxyVendorService(_httpHandlerMock.Object); // Action // Assert Assert.ThrowsExceptionAsync <NotSupportException>(() => service.GetMovieDetail("123")); }
public async Task GetSessionOfMovie_Should_Return_OK_Case_Have_All_Data() { // Arrange dynamic session = new JObject(); session.screenName = "RAP 7"; session.screenNumber = "RAP 7"; session.showDate = "13/10/2019"; session.showTime = "17:00"; dynamic sessions = new JArray(session); dynamic bundle = new JObject(); bundle.caption = "sub"; bundle.version = "2d"; bundle.sessions = sessions; dynamic bundles = new JArray(bundle); dynamic date = new JObject(); date.showDate = "13/10/2019"; date.dayOfWeekLabel = "Chủ nhật"; date.bundles = bundles; dynamic dates = new JArray(date); dynamic sessionMovie = new JObject(); sessionMovie.id = "0e67de8d-8190-45e2-b2aa-aa30468d867f"; sessionMovie.name = "Galaxy Quang Trung"; sessionMovie.phone = "1900 2224"; sessionMovie.address = "Lầu 3, CoopMart Foodcosa số 304A, Quang Trung, P.11, Q. Gò Vấp, Tp.HCM"; sessionMovie.dates = dates; dynamic movies = new JArray(sessionMovie); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(movies.ToString(), System.Text.Encoding.UTF8, "application/json") }; _httpHandlerMock.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response)); var service = new GalaxyVendorService(_httpHandlerMock.Object); // Action var result = await service.GetSessionOfMovie("123"); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); Assert.AreEqual(1, result[0].Dates.Count); Assert.AreEqual(1, result[0].Dates[0].Bundles.Count); Assert.AreEqual(1, result[0].Dates[0].Bundles[0].Sessions.Count); Assert.AreEqual("17:00", result[0].Dates[0].Bundles[0].Sessions[0].ShowTime); }