Fixed async tests
This commit is contained in:
		
							parent
							
								
									37258e563a
								
							
						
					
					
						commit
						2954cfe259
					
				| @ -1,4 +1,6 @@ | ||||
| using System.IO; | ||||
| using System.Threading.Tasks; | ||||
| using Filtration.ObjectModel; | ||||
| using Filtration.Repositories; | ||||
| using Filtration.Services; | ||||
| using Filtration.ViewModels; | ||||
| @ -11,14 +13,14 @@ namespace Filtration.Tests.Repositories | ||||
|     public class TestItemFilterScriptRepository | ||||
|     { | ||||
|         [Test] | ||||
|         public void LoadScriptFromFile_CallsPersistenceServiceUsingPathAndReturnsViewModel() | ||||
|         public async Task LoadScriptFromFile_CallsPersistenceServiceUsingPathAndReturnsViewModel() | ||||
|         { | ||||
|             // Arrange | ||||
|             var testInputPath = "C:\\TestPath.filter"; | ||||
|              | ||||
| 
 | ||||
|             var mockPersistenceService = new Mock<IItemFilterPersistenceService>(); | ||||
|             mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).Verifiable(); | ||||
|             mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).ReturnsAsync(new ItemFilterScript()).Verifiable(); | ||||
|              | ||||
|             var mockItemFilterScriptViewModel = new Mock<IItemFilterScriptViewModel>(); | ||||
|              | ||||
| @ -28,7 +30,7 @@ namespace Filtration.Tests.Repositories | ||||
|             var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object); | ||||
| 
 | ||||
|             // Act | ||||
|             var result = repository.LoadScriptFromFileAsync(testInputPath); | ||||
|             var result = await repository.LoadScriptFromFileAsync(testInputPath); | ||||
| 
 | ||||
|             // Assert | ||||
|             mockPersistenceService.Verify(); | ||||
| @ -36,7 +38,7 @@ namespace Filtration.Tests.Repositories | ||||
|         } | ||||
| 
 | ||||
|         [Test] | ||||
|         public void LoadScriptFromFile_PersistenceServiceThrows_ThrowsIOException() | ||||
|         public async Task LoadScriptFromFile_PersistenceServiceThrows_ThrowsIOException() | ||||
|         { | ||||
|             // Arrange | ||||
|             var testInputPath = "C:\\TestPath.filter"; | ||||
| @ -51,7 +53,7 @@ namespace Filtration.Tests.Repositories | ||||
|             // Act | ||||
|              | ||||
|             // Assert | ||||
|             Assert.Throws<IOException>(() => repository.LoadScriptFromFileAsync(testInputPath)); | ||||
|             Assert.Throws<IOException>(async () => await repository.LoadScriptFromFileAsync(testInputPath)); | ||||
|         } | ||||
| 
 | ||||
|         [Test] | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| using System.IO; | ||||
| using System.Threading.Tasks; | ||||
| using Filtration.Common.Services; | ||||
| using Filtration.ObjectModel; | ||||
| using Filtration.Services; | ||||
| @ -12,7 +13,7 @@ namespace Filtration.Tests.Services | ||||
|     public class TestItemFilterPersistenceService | ||||
|     { | ||||
|         [Test] | ||||
|         public void LoadItemFilterScript_CallsTranslatorAndFileSystemService() | ||||
|         public async Task LoadItemFilterScript_CallsTranslatorAndFileSystemService() | ||||
|         { | ||||
|             // Arrange | ||||
|             const string TestInputPath = "C:\\Test Path\\Script.Filter"; | ||||
| @ -28,7 +29,7 @@ namespace Filtration.Tests.Services | ||||
|             var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object); | ||||
| 
 | ||||
|             // Act | ||||
|             var script = service.LoadItemFilterScriptAsync(TestInputPath); | ||||
|             var script = await service.LoadItemFilterScriptAsync(TestInputPath); | ||||
| 
 | ||||
|             // Assert | ||||
|             mockFileSystemService.Verify(); | ||||
| @ -37,7 +38,7 @@ namespace Filtration.Tests.Services | ||||
|         } | ||||
| 
 | ||||
|         [Test] | ||||
|         public void SaveItemFilterScript_CallsTranslatorAndFileSystemService() | ||||
|         public async Task SaveItemFilterScript_CallsTranslatorAndFileSystemService() | ||||
|         { | ||||
|             // Arrange | ||||
|             var testFilePath = "C:\\Test\\File.txt"; | ||||
| @ -53,7 +54,7 @@ namespace Filtration.Tests.Services | ||||
|             var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object); | ||||
| 
 | ||||
|             // Act | ||||
|             service.SaveItemFilterScriptAsync(testScript); | ||||
|             await service.SaveItemFilterScriptAsync(testScript); | ||||
| 
 | ||||
|             // Assert | ||||
|             mockFileSystemService.Verify(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user