public async Task GetById_ReturnsAIActionResult_WithAFolderFromDatabase() { // Arrange var expected = "Test One";//Name of folder var mockDb = new Mock <IEFFileFolderContext>(); mockDb.Setup(repo => repo.GetFolderByIdAsync(1)) .ReturnsAsync(GetOneTestSessions()); var mockHub = new Mock <IHubContext <FolderHub> >(); var controller = new FolderController(mockDb.Object, mockHub.Object); // Act var result = await controller.Get(1); // Assert //var okObjectResult = result as OkObjectResult; var okObjectResult = Assert.IsType <OkObjectResult>(result); Assert.NotNull(okObjectResult); var model = okObjectResult.Value as FolderResponse; Assert.NotNull(model); var actual = model.FolderName; Assert.Equal(expected, actual); }
public async Task Get_ReturnsAIActionResult_WithAListOfFoldersInDatabase() { // Arrange var expected = 2;//Number of folders in list var mockDb = new Mock <IEFFileFolderContext>(); mockDb.Setup(repo => repo.GetFolders()) .ReturnsAsync(GetAllTestSessions()); var mockHub = new Mock <IHubContext <FolderHub> >(); var controller = new FolderController(mockDb.Object, mockHub.Object); // Act var result = await controller.Get(); // Assert //var okObjectResult = result as OkObjectResult; var okObjectResult = Assert.IsType <OkObjectResult>(result); Assert.NotNull(okObjectResult); var model = okObjectResult.Value as IEnumerable <FolderResponse>; Assert.NotNull(model); var actual = model.Count(); Assert.Equal(expected, actual); }