Exemplo n.º 1
0
        public async Task Index_ReturnsAViewResult_WithAListOfMemorys()
        {
            // Arrange
            var mockMemoryService = new Mock <IService <IRepository <Memory>, Memory> >();

            mockMemoryService.Setup(repo => repo.GetAllAsync())
            .ReturnsAsync(GetTestMemorys());
            var controller = new MemoryController(mockMemoryService.Object);

            // Act
            var result = await controller.Index();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IEnumerable <Memory> >(
                viewResult.ViewData.Model);

            Assert.Equal(2, model.Count());
        }