public async void ComponentTest_Return_NotFoundResult() { var mock = new Mock <IFileManager>(); var component = new ComponentController(mock.Object); var result = await component.GetId(null); Assert.IsType <NotFoundResult>(result); }
public async void ComponentTest_Return_By_Id_OkResult() { // не работает ? не знаю почему string fileId = "5cb45392fedbf916603e0fd5"; var mock = new Mock <IFileManager>(); var componentService = new ComponentController(mock.Object); var component = await componentService.GetId(fileId); Assert.IsType <OkObjectResult>(component); }
public async void ComponentTest_Match_Result() { string fileId = "5cb45392fedbf916603e0fd5"; var mock = new Mock <IFileManager>(); mock.Setup(repo => repo.GetbyId(fileId)).ReturnsAsync(GetTestComponent().FirstOrDefault(p => p.FileId == fileId)); var componentService = new ComponentController(mock.Object); var result = await componentService.GetId(fileId); var viewResult = Assert.IsType <OkObjectResult>(result); var model = Assert.IsType <StoredFile>(viewResult.Value); Assert.Equal("Promise.txt", model.FileName); Assert.Equal(671, model.Size); Assert.Equal(fileId, model.FileId); }