public async Task <bool> ImportAsync(GraphSocDatasetModel?graphSocDataset) { _ = graphSocDataset ?? throw new ArgumentNullException(nameof(graphSocDataset)); try { logger.LogInformation($"Importing SOC dataset to Graph: {graphSocDataset.Soc}"); var commands = graphConnector.BuildImportCommands(graphSocDataset); logger.LogInformation($"Importing SOC dataset to Graph: {graphSocDataset.Soc}: executing commands"); await graphConnector.RunAsync(commands).ConfigureAwait(false); logger.LogInformation($"Imported SOC dataset to Graph: {graphSocDataset.Soc}"); return(true); } catch (Exception ex) { logger.LogError(ex, $"Error received importing data to graphs database for LMI SOC: {graphSocDataset.Soc}"); return(false); } }
public async Task GraphServiceImportReturnsSuccess() { // arrange const bool expectedResult = true; var graphSocDataset = A.Dummy <GraphSocDatasetModel>(); A.CallTo(() => fakeGraphConnector.BuildImportCommands(A <GraphSocDatasetModel> .Ignored)).Returns(A.CollectionOfDummy <string>(2)); // act var result = await graphService.ImportAsync(graphSocDataset, GraphReplicaSet.Draft).ConfigureAwait(false); // assert A.CallTo(() => fakeGraphConnector.BuildImportCommands(A <GraphSocDatasetModel> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => fakeGraphConnector.RunAsync(A <IList <string> > .Ignored, A <GraphReplicaSet> .Ignored)).MustHaveHappenedOnceExactly(); Assert.Equal(expectedResult, result); }