コード例 #1
0
        public async Task Test_GetMovieDetails_NoSuccess()
        {
            // arrange
            var responseData = new GetMovieDetailResponse
            {
                IsOK          = "false",
                ResultMessage = "NOT FOUND"
            };

            _requesterMock
            .Setup(x => x.Post <GetMovieDetailResponse>(
                       It.IsAny <string>(),
                       It.Is <string>(y => y.Contains("representationMovieCode:'10001'")),
                       It.IsAny <string>()))
            .ReturnsAsync(responseData);

            // action
            var service  = new LotteService(_requesterMock.Object);
            var response = await service.GetMovieDetails("10001");

            // assert
            Assert.IsFalse(response.Success);
            Assert.IsNull(response.Data);
            Assert.AreEqual("NOT FOUND", response.Message);
        }
コード例 #2
0
        public async Task Test_GetMovieDetails_Success()
        {
            // arrange
            var responseData = new GetMovieDetailResponse
            {
                IsOK          = "true",
                ResultMessage = "SUCCESS",
                Movie         = new LotteMovie
                {
                    RepresentationMovieCode = "10001",
                    MovieName      = "Movie 1",
                    ReleaseDate    = "20191129",
                    ViewEvaluation = (decimal)7.34,
                    Synopsis       = "Description 1"
                }
            };

            _requesterMock
            .Setup(x => x.Post <GetMovieDetailResponse>(
                       It.IsAny <string>(),
                       It.Is <string>(y => y.Contains("representationMovieCode:'10001'")),
                       It.IsAny <string>()))
            .ReturnsAsync(responseData);

            // action
            var service  = new LotteService(_requesterMock.Object);
            var response = await service.GetMovieDetails("10001");

            // assert
            Assert.IsTrue(response.Success);
            Assert.AreEqual("10001", response.Data.Id);
            Assert.AreEqual("Movie 1", response.Data.Name);
            Assert.AreEqual(new DateTime(2019, 11, 29), response.Data.ReleaseDate);
            Assert.AreEqual((decimal)7.34, response.Data.Rating);
            Assert.AreEqual("Description 1", response.Data.Description);
        }