void VerifyInsertWhenUsingIInsertResultsAbstract(PersistenceTestData <IInsertViaFileResults> inTestData)
        {
            // Create a number of temporary files, empty, and put their names in filePaths
            var temporaryFiles = new TemporaryFile[inTestData.NumberOfContainers];
            var filePaths      = new string[inTestData.NumberOfContainers];

            for (int i = 0; i < inTestData.NumberOfContainers; i++)
            {
                temporaryFiles[i] = new TemporaryFile().CreateTemporaryFileEmpty();
                filePaths[i]      = temporaryFiles[i].FileInfo.FullName;
            }
            ;

            // Call the SetupViaFileFuncBuilder here, execute the Func that comes back, with filePaths as the argument
            var setupResults = ATAP.Utilities.Persistence.Extensions.SetupViaFileFuncBuilder()(new SetupViaFileData(filePaths));

            // Validate the results are as expected
            setupResults.Success.Should().Be(true);
            setupResults.FileStreamStreamWriterPairs.Length.Should().Be(inTestData.NumberOfContainers);
            // Create an insertFunc that references the local variable setupResults, closing over it
            var insertFunc = new Func <IEnumerable <IEnumerable <object> >, IInsertViaFileResults>((insertData) =>
            {
                int numberOfFiles = insertData.ToArray().Length;
#if DEBUG
                TestOutput.WriteLine($"Got {numberOfFiles} arrays of data to write");
#endif
                int numberOfFileStreamStreamWriterPairs = setupResults.FileStreamStreamWriterPairs.Length;
#if DEBUG
                TestOutput.WriteLine($"Got {numberOfFileStreamStreamWriterPairs} streamwriters to write to");
#endif
                for (var i = 0; i < numberOfFiles; i++)
                {
                    foreach (string str in insertData.ToArray()[i])
                    {
                        //ToDo: add async versions await setupResults.StreamWriters[i].WriteLineAsync(str);
                        //ToDo: exception handling
                        setupResults.FileStreamStreamWriterPairs[i].streamWriter.WriteLine(str);
#if DEBUG
                        TestOutput.WriteLine($"writing {str} to file {i}");
#endif
                    }
                }
                return(new InsertViaFileResults(true));
            });

            Persistence <IInsertResultsAbstract> persistence = new Persistence <IInsertResultsAbstract>(insertFunc);
            // Create a simple function whose only tasks is to write some data to the persistence files, and return
            Action <IPersistence <IInsertResultsAbstract> > SimpleAction = new Action <IPersistence <IInsertResultsAbstract> >((persistence) =>
            {
                // Insert the data to the persistence mechanism
                var insertResults = persistence.InsertEnumerableFunc(inTestData.ObjectsForEachContainer);
                insertResults.Success.Should().Be(true); // Only inside of tests
            });

            // Execute the SimpleAction, which at completion exits the closure over setupResults
            SimpleAction(persistence);

            // Dispose of the persistence setupResults
            setupResults.Dispose();

            // did we get the data we expected
            long CountLinesLINQ(FileInfo file) => File.ReadLines(file.FullName).Count();

            for (int i = 0; i < inTestData.NumberOfContainers; i++)
            {
                CountLinesLINQ(temporaryFiles[i].FileInfo).Should().Be(inTestData.ObjectsForEachContainer.ToArray()[i].Count());
            }
        }
        void VerifyInsert(PersistenceTestData <IInsertViaFileResults> inTestData)
        {
            // Create a number of temporary files, empty, and put their names in filePaths
            var temporaryFiles = new TemporaryFile[inTestData.NumberOfContainers];
            var filePaths      = new string[inTestData.NumberOfContainers];

            for (int i = 0; i < inTestData.NumberOfContainers; i++)
            {
                temporaryFiles[i] = new TemporaryFile().CreateTemporaryFileEmpty();
                filePaths[i]      = temporaryFiles[i].FileInfo.FullName;
            }

            // Call the SetupViaFileFuncBuilder here, execute the Func that comes back, with filePaths as the argument
            var setupResults = ATAP.Utilities.Persistence.Extensions.SetupViaFileFuncBuilder()(new SetupViaFileData(filePaths));

            setupResults.Success.Should().Be(true);

            var insertFunc = new Func <IEnumerable <IEnumerable <object> >, IInsertViaFileResults>((insertData) =>
            {
                int numberOfFiles = insertData.ToArray().Length;
#if DEBUG
                TestOutput.WriteLine($"Got {numberOfFiles} arrays of data to write");
#endif
                int numberOfFileStreamStreamWriterPairs = setupResults.FileStreamStreamWriterPairs.Length;
#if DEBUG
                TestOutput.WriteLine($"Got {numberOfFileStreamStreamWriterPairs} streamwriters to write to");
#endif
                for (var i = 0; i < numberOfFileStreamStreamWriterPairs; i++)
                {
                    foreach (string str in insertData.ToArray()[i])
                    {
                        //ToDo: add async versions await setupResults.StreamWriters[i].WriteLineAsync(str);
                        //ToDo: exception handling
                        setupResults.FileStreamStreamWriterPairs[i].streamWriter.WriteLine(str);
#if DEBUG
                        TestOutput.WriteLine($"writing {str} to file {i}");
#endif
                    }
                }
                return(new InsertViaFileResults(true));
            });

            //IEnumerable<IEnumerable<object>> dataToInsert = inTestData.ObjectsForEachContainer;
            IEnumerable <object>[] containersToInsert = inTestData.ObjectsForEachContainer.ToArray();
            string[][]             dataToInsert       = new string[containersToInsert.Count()][];
            for (var i = 0; i < containersToInsert.Count(); i++)
            {
                object[] objArray = containersToInsert[i].ToArray();
                //string[] strArray =  as string[];

                dataToInsert[i] = objArray.Select(x => x.ToString()) as string[];
            }

            var insertResults = insertFunc(dataToInsert);

            insertResults.Success.Should().Be(true);
            setupResults.Dispose();
            long CountLinesLINQ(FileInfo file) => File.ReadLines(file.FullName).Count(); // replace with a File Utility https://www.nimaara.com/, or pull in his library

            for (int i = 0; i < inTestData.NumberOfContainers; i++)
            {
                CountLinesLINQ(temporaryFiles[i].FileInfo).Should().Be(inTestData.ObjectsForEachContainer.ToArray()[i].Count());
            }
        }