Ejemplo n.º 1
0
        public void ConvertBirthDayFromEntityToResponse()
        {
            //collect data
            int pageSize = 50;
            int page     = 1;

            var testShowCollection = GetTestShowCollection();

            ShowDataService.Setup(s => s.GetShowAndCastData(page, pageSize)).Returns(testShowCollection);

            //convert to Json response
            var showController = new ShowController(ShowDataService.Object);
            var actionResult   = showController.ShowsWithCast(page, pageSize);

            //check for valid actionresult type
            var result = actionResult as OkObjectResult;

            Assert.IsNotNull(result);

            //check for valid responsetype
            var resultContent = result.Value as List <ShowResponse>;

            Assert.IsNotNull(resultContent);

            //the amount of shows should be the same as what we started with
            Assert.AreEqual(1, resultContent.Count);

            var castMembers = resultContent.First().Cast;

            //first show should have 3 cast members
            Assert.AreEqual(3, castMembers.Count);

            //check the datetime values for correctness
            foreach (var cast in castMembers)
            {
                //expect max 10 characters yyyy-MM-dd
                Assert.AreEqual(10, cast.BirthDayDate.Length);
            }
        }