diff --git a/Code/Mantid/Framework/DataHandling/test/LoadTest.h b/Code/Mantid/Framework/DataHandling/test/LoadTest.h index e0d7a66c547d967e8e2cf0514ee3b17e619cfcea..b017db16ae94c6108d26b061b0b6bd2fc453f580 100644 --- a/Code/Mantid/Framework/DataHandling/test/LoadTest.h +++ b/Code/Mantid/Framework/DataHandling/test/LoadTest.h @@ -9,6 +9,8 @@ #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/AlgorithmManager.h" +#include <boost/algorithm/string/predicate.hpp> //for ends_with + using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::DataHandling; @@ -90,17 +92,17 @@ public: { Load loader; loader.initialize(); - const char * loadraw_props[5] = {"SpectrumMin", "SpectrumMax", "SpectrumList", "Cache", "LoadLogFiles"}; - const size_t numProps = (size_t)(sizeof(loadraw_props)/sizeof(const char*)); + static const size_t NUMPROPS = 5; + const char * loadraw_props[NUMPROPS] = {"SpectrumMin", "SpectrumMax", "SpectrumList", "Cache", "LoadLogFiles"}; // Basic load has no additional loader properties - for( size_t i = 0; i < numProps ; ++i ) + for( size_t i = 0; i < NUMPROPS ; ++i ) { TS_ASSERT_EQUALS(loader.existsProperty(loadraw_props[i]), false); } //After setting the file property, the algorithm should have aquired the appropriate properties TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename","IRS38633.raw")); // Now - for( size_t i = 0; i < numProps; ++i ) + for( size_t i = 0; i < NUMPROPS; ++i ) { TS_ASSERT_EQUALS(loader.existsProperty(loadraw_props[i]), true); } @@ -109,477 +111,150 @@ public: TS_ASSERT_EQUALS(loader.getPropertyValue("LoaderName"), "LoadRaw"); } - void testRaw() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","IRS38633.raw"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - loader.setRethrows(true); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } - - void testRawWithOneSpectrum() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","IRS38633.raw"); - const std::string outputName("LoadTest_IRS38633raw"); - loader.setPropertyValue("OutputWorkspace", outputName); - loader.setPropertyValue("SpectrumList", "1"); - loader.setRethrows(true); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - TS_ASSERT_EQUALS(loader.isExecuted(), true); - - AnalysisDataServiceImpl& dataStore = AnalysisDataService::Instance(); - TS_ASSERT_EQUALS(dataStore.doesExist(outputName), true); - - MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>(dataStore.retrieve(outputName)); - if(!ws) TS_FAIL("Cannot retrieve workspace from the store"); - - // Check it only has 1 spectrum - TS_ASSERT_EQUALS( ws->getNumberHistograms(), 1 ); - } - - void testRaw1() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","CSP74683.s02"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } - - void testRawGroup() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","CSP79590.raw"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - WorkspaceGroup_sptr wsg = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(wsg); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output_1"); - TS_ASSERT(ws); - - } - - void testHDF4Nexus() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","emu00006473.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } - - void _ARGUS_NXS() - { - Load loader; - loader.initialize(); - TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename","argus0026287.nxs")); - - TS_ASSERT_EQUALS(loader.getPropertyValue("LoaderName"), "LoadMuonNexus"); - } - - void testHDF4NexusGroup() - { - // Note that there are no 64-bit HDF4 libraries for Windows. - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","MUSR00015189.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - WorkspaceGroup_sptr wsg = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(wsg); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output_1"); - TS_ASSERT(ws); - } - void testISISNexus() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","LOQ49886.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } - - void testUnknownExt() + void test_Comma_Separated_List_Finds_Correct_Number_Of_Files() { Load loader; loader.initialize(); - TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename","hrpd_new_072_01.cal")); - } + loader.setPropertyValue("Filename", "MUSR15189,15190,15191.nxs"); - void testSPE() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","Example.spe"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } - - void testAscii() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","AsciiExample.txt"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } + std::vector<std::vector<std::string> > foundFiles = loader.getProperty("Filename"); - void testSpice2D() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","BioSANS_exp61_scan0004_0001.xml"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } - void testSNSSpec() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","LoadSNSspec.txt"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); + // Outer vector holds separate lists of files to be summed together + // In this case no summing required + TS_ASSERT_EQUALS(3, foundFiles.size()); + // Inner vector holds files to be summed + TS_ASSERT_EQUALS(1, foundFiles[0].size()); + TS_ASSERT_EQUALS(1, foundFiles[1].size()); + TS_ASSERT_EQUALS(1, foundFiles[2].size()); } - void testGSS() + void test_Plus_Operator_Finds_Correct_Number_Of_Files() { Load loader; loader.initialize(); - loader.setPropertyValue("Filename","gss.txt"); - // Check correct loader identified - TS_ASSERT_EQUALS(loader.getPropertyValue("LoaderName"), "LoadGSS"); - - Load loader2; - loader2.initialize(); - loader2.setPropertyValue("Filename","gss-ExtendedHeader.gsa"); - // Check correct loader identified - TS_ASSERT_EQUALS(loader2.getPropertyValue("LoaderName"), "LoadGSS"); - } + loader.setPropertyValue("Filename", "IRS38633+38633.nxs"); - void testRKH() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename","DIRECT.041"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } + std::vector<std::vector<std::string> > foundFiles = loader.getProperty("Filename"); - void test_EventPreNeXus_WithNoExecute() - { - Load loader; - loader.initialize(); - TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename", "CNCS_7860_neutron_event.dat")); - TS_ASSERT_EQUALS(loader.existsProperty("EventFilename"), false); - TS_ASSERT_EQUALS(loader.getPropertyValue("LoaderName"), "LoadEventPreNexus"); + // Outer vector holds separate lists of files to be summed together + TS_ASSERT_EQUALS(1, foundFiles.size()); + // Inner vector holds files to be summed + TS_ASSERT_EQUALS(2, foundFiles[0].size()); } - void test_SNSEventNeXus_WithNoExecute() + void test_Range_Operator_Finds_Correct_Number_Of_Files() { Load loader; loader.initialize(); - TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename", "CNCS_7860_event.nxs")); - TS_ASSERT_EQUALS(loader.existsProperty("EventFilename"), false); - TS_ASSERT_EQUALS(loader.getPropertyValue("LoaderName"), "LoadEventNexus"); - } + loader.setPropertyValue("Filename", "MUSR15189:15192.nxs"); - void testDaveGrp() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "DaveAscii.grp"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); - } + std::vector<std::vector<std::string> > foundFiles = loader.getProperty("Filename"); - void testArgusFileLoadingWithIncorrectZeroPadding() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "argus0026287.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(ws); + // Outer vector holds separate lists of files to be summed together + // In this case no summing required + TS_ASSERT_EQUALS(4, foundFiles.size()); + // Inner vector holds files to be summed + TS_ASSERT_EQUALS(1, foundFiles[0].size()); + TS_ASSERT_EQUALS(1, foundFiles[1].size()); + TS_ASSERT_EQUALS(1, foundFiles[2].size()); + TS_ASSERT_EQUALS(1, foundFiles[3].size()); } - void testMDWorkspace() + void test_Stepped_Range_Operator_Finds_Correct_Number_Of_Files() { Load loader; loader.initialize(); - loader.setPropertyValue("Filename", "SEQ_MDEW.nxs"); - const std::string outputWS("MDWS"); - loader.setPropertyValue("OutputWorkspace",outputWS); - TS_ASSERT( loader.execute() ); - TS_ASSERT_THROWS_NOTHING( AnalysisDataService::Instance().retrieveWS<IMDWorkspace>(outputWS) ); - } - - void testList() - { - AnalysisDataService::Instance().clear(); - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "MUSR15189,15190,15191.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - WorkspaceGroup_sptr output = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(output); - TS_ASSERT_EQUALS(output->getNumberOfEntries(),6); - MatrixWorkspace_sptr ws1 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_1"); - TS_ASSERT(ws1); - MatrixWorkspace_sptr ws2 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_2"); - TS_ASSERT(ws2); - MatrixWorkspace_sptr ws3 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015190_1"); - TS_ASSERT(ws3); - MatrixWorkspace_sptr ws4 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015190_2"); - TS_ASSERT(ws4); - MatrixWorkspace_sptr ws5 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015191_1"); - TS_ASSERT(ws5); - MatrixWorkspace_sptr ws6 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015191_2"); - TS_ASSERT(ws6); - - // Check that originally loaded groups are not left in the ADS - TS_ASSERT(!AnalysisDataService::Instance().doesExist("MUSR00015189")); - TS_ASSERT(!AnalysisDataService::Instance().doesExist("MUSR00015190")); - TS_ASSERT(!AnalysisDataService::Instance().doesExist("MUSR00015191")); - } + loader.setPropertyValue("Filename", "MUSR15189:15192:2.nxs"); - void testPlus() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "IRS38633+38633.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); + std::vector<std::vector<std::string> > foundFiles = loader.getProperty("Filename"); - MatrixWorkspace_sptr output = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("LoadTest_Output"); - TS_ASSERT(output); - } + // Outer vector holds separate lists of files to be summed together + // In this case no summing required + TS_ASSERT_EQUALS(2, foundFiles.size()); + // Inner vector holds files to be summed + TS_ASSERT_EQUALS(1, foundFiles[0].size()); + TS_ASSERT_EQUALS(1, foundFiles[1].size()); - void testPlusGroupWorkspaces() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "MUSR15189+15190.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - - WorkspaceGroup_sptr output = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(output); - MatrixWorkspace_sptr ws1 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_MUSR00015190_1"); - TS_ASSERT(ws1); - MatrixWorkspace_sptr ws2 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_MUSR00015190_2"); - } + // Check it has found the correct two + const std::string first = foundFiles[0][0]; + TSM_ASSERT(std::string("Incorrect first file has been found: ") + first, boost::algorithm::ends_with(first, "MUSR00015189.nxs")); + const std::string second = foundFiles[1][0]; + TSM_ASSERT(std::string("Incorrect second file has been found") + second, boost::algorithm::ends_with(second, "MUSR00015191.nxs")); - void testRange() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "MUSR15189:15192.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - WorkspaceGroup_sptr output = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(output); - TS_ASSERT_EQUALS(output->getNumberOfEntries(),8); - MatrixWorkspace_sptr ws1 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_1"); - TS_ASSERT(ws1); - MatrixWorkspace_sptr ws2 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_2"); - TS_ASSERT(ws2); - MatrixWorkspace_sptr ws3 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015190_1"); - TS_ASSERT(ws3); - MatrixWorkspace_sptr ws4 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015190_2"); - TS_ASSERT(ws4); - MatrixWorkspace_sptr ws5 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015191_1"); - TS_ASSERT(ws5); - MatrixWorkspace_sptr ws6 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015191_2"); - TS_ASSERT(ws6); - MatrixWorkspace_sptr ws7 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015192_1"); - TS_ASSERT(ws7); - MatrixWorkspace_sptr ws8 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015192_2"); - TS_ASSERT(ws8); + // A more through test of the loading and value checking is done in the LoadTest.py system test } - void testSteppedRange() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "MUSR15189:15192:2.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - WorkspaceGroup_sptr output = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(output); - TS_ASSERT_EQUALS(output->getNumberOfEntries(),4); - MatrixWorkspace_sptr ws1 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_1"); - TS_ASSERT(ws1); - MatrixWorkspace_sptr ws2 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_2"); - TS_ASSERT(ws2); - MatrixWorkspace_sptr ws3 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015191_1"); - TS_ASSERT(ws3); - MatrixWorkspace_sptr ws4 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015191_2"); - TS_ASSERT(ws4); - } - - void testAddedRange() + void test_Added_Range_Operator_Finds_Correct_Number_Of_Files() { Load loader; loader.initialize(); loader.setPropertyValue("Filename", "MUSR15189-15192.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - - WorkspaceGroup_sptr output = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(output); - TS_ASSERT_EQUALS(output->getNumberOfEntries(),2); - MatrixWorkspace_sptr ws1 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_MUSR00015190_MUSR00015191_MUSR00015192_1"); - TS_ASSERT(ws1); - TS_ASSERT_DELTA(ws1->readY(0)[0], 16.0, 1e-12); - TS_ASSERT_DELTA(ws1->readY(6)[4], 1.0, 1e-12); - - MatrixWorkspace_sptr ws2 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_MUSR00015190_MUSR00015191_MUSR00015192_2"); - TS_ASSERT(ws2); - TS_ASSERT_DELTA(ws2->readY(0)[5], 2.0, 1e-12); - TS_ASSERT_DELTA(ws2->readY(8)[0], 6.0, 1e-12); - } - void testAddedSteppedRange() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "MUSR15189-15192:2.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - - WorkspaceGroup_sptr output = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(output); - TS_ASSERT_EQUALS(output->getNumberOfEntries(),2); - MatrixWorkspace_sptr ws1 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_MUSR00015191_1"); - TS_ASSERT(ws1); - MatrixWorkspace_sptr ws2 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("MUSR00015189_MUSR00015191_2"); - TS_ASSERT(ws2); - } + std::vector<std::vector<std::string> > foundFiles = loader.getProperty("Filename"); - void testMultiFilesExtraProperties() - { - IAlgorithm_sptr proxy = AlgorithmManager::Instance().create("Load"); + // Outer vector holds separate lists of files to be summed together + // In this case no summing required + TS_ASSERT_EQUALS(1, foundFiles.size()); + // Inner vector holds files to be summed + TS_ASSERT_EQUALS(4, foundFiles[0].size()); - TS_ASSERT_THROWS_NOTHING(proxy->setPropertyValue("Filename","IRS21360,26173,38633.raw")); - TS_ASSERT_THROWS_NOTHING(proxy->setPropertyValue("OutputWorkspace","test")); + // Check it has found the correct two + const std::string first = foundFiles[0][0]; + TSM_ASSERT(std::string("Incorrect first file has been found: ") + first, boost::algorithm::ends_with(first, "MUSR00015189.nxs")); + const std::string last = foundFiles[0][3]; + TSM_ASSERT(std::string("Incorrect last file has been found") + last, boost::algorithm::ends_with(last, "MUSR00015192.nxs")); - TS_ASSERT_THROWS_NOTHING(proxy->setPropertyValue("SpectrumMin","10")); - TS_ASSERT_THROWS_NOTHING(proxy->setPropertyValue("SpectrumMax","100")); - - TS_ASSERT_THROWS_NOTHING(proxy->execute()); - - // get result - WorkspaceGroup_sptr wsg = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("test"); - TS_ASSERT(wsg); - - // get first ws in group - std::vector<std::string> childNames = wsg->getNames(); - MatrixWorkspace_sptr childWs = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(childNames[0]); - TS_ASSERT(childWs); - - // Make sure that it contains the requested number of spectra as per SpectrumMin and SpectrumMax - TS_ASSERT_EQUALS(childWs->getNumberHistograms(), 91); + // A more through test of the loading and value checking is done in the LoadTest.py system test } - void testCommaSeparatedListOfDifferentIntruments() + void test_Comma_Separated_List_Of_Different_Intruments_Finds_Correct_Files() { Load loader; loader.initialize(); loader.setPropertyValue("Filename", "LOQ48127.raw, CSP79590.raw"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - WorkspaceGroup_sptr wsg = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(wsg); - TS_ASSERT_EQUALS(wsg->getNames().size(), 3); - } + std::vector<std::vector<std::string> > foundFiles = loader.getProperty("Filename"); - void test_outputWsNameSameAsOneOfTheSinglePeriodFileNames() - { - Load loader; - loader.initialize(); - loader.setPropertyValue("Filename", "LOQ48127.raw, CSP79590.raw"); - loader.setPropertyValue("OutputWorkspace","LOQ48127"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); + // Outer vector holds separate lists of files to be summed together + // In this case no summing required + TS_ASSERT_EQUALS(2, foundFiles.size()); + // Inner vector holds files to be summed + TS_ASSERT_EQUALS(1, foundFiles[0].size()); + TS_ASSERT_EQUALS(1, foundFiles[1].size()); - WorkspaceGroup_sptr wsg = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LOQ48127"); - TS_ASSERT(wsg); - TS_ASSERT_EQUALS(wsg->getNames().size(), 3); + // Check it has found the correct two + const std::string first = foundFiles[0][0]; + TSM_ASSERT(std::string("Incorrect first file has been found: ") + first, boost::algorithm::ends_with(first, "LOQ48127.raw")); + const std::string second = foundFiles[1][0]; + TSM_ASSERT(std::string("Incorrect second file has been found") + second, boost::algorithm::ends_with(second, "CSP79590.raw")); } - void test_cleanupAfterMultifileLoading() + void test_EventPreNeXus_WithNoExecute() { Load loader; loader.initialize(); - loader.setPropertyValue("Filename", "MUSR15189-15192:2.nxs"); - loader.setPropertyValue("OutputWorkspace","LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - - TS_ASSERT_EQUALS(3, AnalysisDataService::Instance().size()); - - const auto wsg = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("LoadTest_Output"); - TS_ASSERT(wsg); - TS_ASSERT_EQUALS(wsg->getNames().size(), 2); - } - - void test_additionalOutputWorkspaces_mandatory() - { - // TODO: This is supposed to be a test for load algorithm with additional _mandatory_ output - // workspace properties, which should be set to something by Load so the concrete algorithm - // can actually be run. At the present moment, I wasn't able to find any algorithms with - // such properties, so please feel free to write this one when it becomes possible. + TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename", "CNCS_7860_neutron_event.dat")); + TS_ASSERT_EQUALS(loader.existsProperty("EventFilename"), false); + TS_ASSERT_EQUALS(loader.getPropertyValue("LoaderName"), "LoadEventPreNexus"); } - void test_additionalOutputWorkspaces_optional_notRequested() + void test_SNSEventNeXus_WithNoExecute() { Load loader; loader.initialize(); - loader.setPropertyValue("Filename", "MUSR15189"); - loader.setPropertyValue("OutputWorkspace", "LoadTest_Output"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - - TS_ASSERT_EQUALS(3, AnalysisDataService::Instance().size()); + TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename", "CNCS_7860_event.nxs")); + TS_ASSERT_EQUALS(loader.existsProperty("EventFilename"), false); + TS_ASSERT_EQUALS(loader.getPropertyValue("LoaderName"), "LoadEventNexus"); } - void test_additionalOutputWorskpaces_optional_requested() + void testArgusFileWithIncorrectZeroPadding_NoExecute() { Load loader; loader.initialize(); - loader.setPropertyValue("Filename", "MUSR15189"); - loader.setPropertyValue("OutputWorkspace", "LoadTest_Output"); - loader.setPropertyValue("DetectorGroupingTable", "LoadTest_DetectorGrouping"); - loader.setPropertyValue("DeadTimeTable", "LoadTest_DeadTimeTable"); - TS_ASSERT_THROWS_NOTHING(loader.execute()); - - TS_ASSERT_EQUALS(9, AnalysisDataService::Instance().size()); + loader.setPropertyValue("Filename", "argus0026287.nxs"); + TS_ASSERT_EQUALS(loader.getPropertyValue("LoaderName"), "LoadMuonNexus"); } + };