Пример #1
0
        public void TestConfigEquals()
        {
            TestUtils.InitializeInstallations();
            var testConfig = TestUtils.GetTestConfig();

            Assert.IsTrue(Equals(testConfig, TestUtils.GetTestConfig()));
            Assert.IsFalse(Equals(testConfig, TestUtils.GetTestConfig("other")));

            var differentReportSettings = new SkylineBatchConfig("name", DateTime.MinValue, DateTime.MinValue, TestUtils.GetTestMainSettings(), new ReportSettings(new List <ReportInfo>()), new SkylineSettings(SkylineType.Skyline));

            Assert.IsFalse(Equals(testConfig, differentReportSettings));

            var differentMain = new MainSettings(testConfig.MainSettings.TemplateFilePath,
                                                 TestUtils.GetTestFilePath(""), testConfig.MainSettings.DataFolderPath,
                                                 testConfig.MainSettings.ReplicateNamingPattern);
            var differentMainSettings = new SkylineBatchConfig("name", DateTime.MinValue, DateTime.MinValue, differentMain, TestUtils.GetTestReportSettings(), new SkylineSettings(SkylineType.Skyline));

            Assert.IsFalse(Equals(testConfig, differentMainSettings));
        }
Пример #2
0
        public void TestValidateConfig()
        {
            TestUtils.InitializeInstallations();
            var validName       = "Name";
            var invalidName     = "";
            var validSkyr       = TestUtils.GetTestFilePath("UniqueReport.skyr");
            var invalidSkyr     = "invalidPath.skyr";
            var validRScripts   = new List <Tuple <string, string> >();
            var invalidRscripts = new List <Tuple <string, string> > {
                new Tuple <string, string>("invalidPath.r", "1.2.3")
            };

            TestValidateReportSettings(validName, invalidSkyr, validRScripts, "Report \"Name\": Report path invalidPath.skyr is not a valid path.");
            TestValidateReportSettings(validName, validSkyr, invalidRscripts, "Report \"Name\": R script path invalidPath.r is not a valid path.");
            TestValidateReportSettings(invalidName, validSkyr, validRScripts, "Report must have name.");
            try
            {
                var validReport = new ReportInfo(validName, validSkyr, validRScripts);
                validReport.Validate();
            }
            catch (Exception)
            {
                Assert.Fail("Should have validated valid ReportInfo");
            }

            var validTemplatePath     = TestUtils.GetTestFilePath("emptyTemplate.sky");
            var invalidTemplatePath   = TestUtils.GetTestFilePath("nonexistent.sky");
            var validAnalysisFolder   = TestUtils.GetTestFilePath("") + "folderToCreate";
            var invalidAnalysisFolder = TestUtils.GetTestFilePath("") + @"nonexistentOne\nonexistentTwo\";
            var validDataDir          = TestUtils.GetTestFilePath("emptyData");
            var invalidDataDir        = TestUtils.GetTestFilePath("nonexistentData");
            var validPattern          = "";

            TestValidateMainSettings(invalidTemplatePath, validAnalysisFolder, validDataDir, validPattern,
                                     string.Format("Skyline file {0} does not exist.", invalidTemplatePath));
            TestValidateMainSettings(validTemplatePath, invalidAnalysisFolder, validDataDir, validPattern,
                                     string.Format("Analysis folder directory {0} does not exist.", TestUtils.GetTestFilePath("") + @"nonexistentOne\nonexistentTwo"));
            TestValidateMainSettings(validTemplatePath, validAnalysisFolder, invalidDataDir, validPattern,
                                     string.Format("Data folder {0} does not exist.", invalidDataDir));
            TestValidateMainSettings(invalidTemplatePath, invalidAnalysisFolder, invalidDataDir, validPattern,
                                     string.Format("Skyline file {0} does not exist.", invalidTemplatePath));
            try
            {
                var testValidMainSettings = new MainSettings(validTemplatePath, validAnalysisFolder, validDataDir, null);
                testValidMainSettings.Validate();
            }
            catch (Exception)
            {
                Assert.Fail("Should have validated valid MainSettings");
            }

            var validMainSettings    = new MainSettings(validTemplatePath, validAnalysisFolder, validDataDir, null);
            var validReportSettings  = new ReportSettings(new List <ReportInfo>());
            var validSkylineSettings = new SkylineSettings(SkylineType.Custom, "C:\\Program Files\\Skyline");

            try
            {
                var invalidConfig = new SkylineBatchConfig(invalidName, DateTime.MinValue, DateTime.MinValue, validMainSettings, validReportSettings, validSkylineSettings);
                invalidConfig.Validate();
                Assert.Fail("Should have failed to validate invalid config");
            }
            catch (Exception e)
            {
                Assert.AreEqual("Please enter a name for the configuration.", e.Message);
            }

            try
            {
                var validConfig = new SkylineBatchConfig(validName, DateTime.MinValue, DateTime.MinValue, validMainSettings, validReportSettings, validSkylineSettings);
                validConfig.Validate();
            }
            catch (Exception e)
            {
                Assert.Fail("Should have validated valid config");
            }
        }