public void GetAsync_Return_All_Projections() { //Arrange List <ProjectionDomainModel> projectionsDomainModelsList = new List <ProjectionDomainModel>(); ProjectionDomainModel projectionDomainModel = new ProjectionDomainModel { Id = Guid.NewGuid(), AuditoriumName = "ImeSale", AuditoriumId = 1, MovieId = Guid.NewGuid(), MovieTitle = "ImeFilma", ProjectionTime = DateTime.Now.AddDays(1) }; query = new ProjectionQuery(); projectionsDomainModelsList.Add(projectionDomainModel); IEnumerable <ProjectionDomainModel> projectionDomainModels = projectionsDomainModelsList; Task <IEnumerable <ProjectionDomainModel> > responseTask = Task.FromResult(projectionDomainModels); int expectedResultCount = 1; int expectedStatusCode = 200; _projectionService = new Mock <IProjectionService>(); _projectionService.Setup(x => x.GetAllAsync(query)).Returns(responseTask); ProjectionsController projectionsController = new ProjectionsController(_projectionService.Object); //Act var result = projectionsController.GetAsync(query).ConfigureAwait(false).GetAwaiter().GetResult().Result; var resultList = ((OkObjectResult)result).Value; var projectionDomainModelResultList = (List <ProjectionDomainModel>)resultList; //Assert Assert.IsNotNull(projectionDomainModelResultList); Assert.AreEqual(expectedResultCount, projectionDomainModelResultList.Count); Assert.AreEqual(projectionDomainModel.Id, projectionDomainModelResultList[0].Id); Assert.IsInstanceOfType(result, typeof(OkObjectResult)); Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode); }
public void GetAsync_Return_NewList() { //Arrange IEnumerable <ProjectionDomainModel> projectionDomainModels = null; Task <IEnumerable <ProjectionDomainModel> > responseTask = Task.FromResult(projectionDomainModels); int expectedResultCount = 0; int expectedStatusCode = 200; _projectionService = new Mock <IProjectionService>(); _projectionService.Setup(x => x.GetAllAsync()).Returns(responseTask); ProjectionsController projectionsController = new ProjectionsController(_projectionService.Object); //Act var result = projectionsController.GetAsync().ConfigureAwait(false).GetAwaiter().GetResult().Result; var resultList = ((OkObjectResult)result).Value; var projectionDomainModelResultList = (List <ProjectionDomainModel>)resultList; //Assert Assert.IsNotNull(projectionDomainModelResultList); Assert.AreEqual(expectedResultCount, projectionDomainModelResultList.Count); Assert.IsInstanceOfType(result, typeof(OkObjectResult)); Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode); }