public void LoadDocumentMissingId() { var metadataService = new Mock <IMetadataService>(); metadataService.Setup(x => x.LoadMetadata(It.IsAny <Guid>())).Throws <ArgumentNullException>(); var fileHandlerService = new Mock <IFileHandler>(); var storageHandler = new FilesystemStorageHandler(metadataService.Object, _appSettings, fileHandlerService.Object); Func <Task> t = async() => await storageHandler.LoadDocument(Guid.Empty); t.Should().Throw <ArgumentNullException>(); }
public async void LoadDocumentValid() { var doc = new Document() { Id = Guid.NewGuid(), Metadata = _metadataMock, File = null }; var metadataService = new Mock <IMetadataService>(); metadataService.Setup(x => x.LoadMetadata(It.IsAny <Guid>())).Returns(Task.FromResult(_metadataMock)); var fileHandlerService = new Mock <IFileHandler>(); var storageHandler = new FilesystemStorageHandler(metadataService.Object, _appSettings, fileHandlerService.Object); var result = await storageHandler.LoadDocument(doc.Id); result.Should().BeEquivalentTo(doc); metadataService.Verify(x => x.LoadMetadata(doc.Id)); }