public async Task HeadFile_QueryReturnsEmpty_ReturnsNull() { // Arrange var configRepoMock = new Mock <IConfigRepository>(); configRepoMock.Setup((m) => m.CommandTimeout).Returns(60); var cxn = new SqlConnectionWrapperMock(); var repository = new SqlFilesRepository(cxn.Object, configRepoMock.Object); var guid = new Guid("88888888888888888888888888888888"); File[] result = { }; cxn.SetupQueryAsync( "[FileStore].ReadFileHead", new Dictionary <string, object> { { "FileId", guid } }, result); // Act File file = await repository.GetFileHead(guid); // Assert cxn.Verify(); Assert.IsNull(file); }
public async Task GetHeadFile_QueryReturnsFile_ReturnsFirst() { // Arrange var configRepoMock = new Mock <IConfigRepository>(); configRepoMock.Setup((m) => m.CommandTimeout).Returns(60); var cxn = new SqlConnectionWrapperMock(); var repository = new SqlFilesRepository(cxn.Object, configRepoMock.Object); var guid = new Guid("99999999999999999999999999999999"); File[] result = { new File { FileName = "name", FileType = "type" } }; cxn.SetupQueryAsync( "[FileStore].ReadFileHead", new Dictionary <string, object> { { "FileId", guid } }, result); // Act File file = await repository.GetFileHead(guid); // Assert cxn.Verify(); Assert.AreEqual(result.First(), file); }