예제 #1
0
 public TestRepository(ITestFileReader testFileReader, ITestFileWriter testFileWriter, IFileHandler fileHandler, IConfiguration configuration)
 {
     _testFileReader = testFileReader;
     _testFileWriter = testFileWriter;
     _fileHandler    = fileHandler;
     _configuration  = configuration;
 }
예제 #2
0
 public JsUnitTestRunner(
     [NotNull] IWebServer webServer,
     [NotNull] FixtureRunner fixtureRunner,
     [NotNull] ITestFileReader testFileReader,
     [NotNull] IFixtureFinder fixtureFinder)
 {
     this.webServer      = webServer;
     this.fixtureRunner  = fixtureRunner;
     this.testFileReader = testFileReader;
     this.fixtureFinder  = fixtureFinder;
 }
예제 #3
0
 public SuffixTestFileReader([NotNullOrEmpty] string postFix, [NotNull] ITestFileReader adaptee)
     : base(adaptee)
 {
     this.postFix = postFix;
 }
예제 #4
0
 public void Map(string match, ITestFileReader reader)
 {
     readers.Add(match, reader);
 }
예제 #5
0
 public TestRepository(ITestFileReader testFileReader, ITestFileWriter testFileWriter, IFileHandler fileHandler)
 {
     _testFileReader = testFileReader;
     _testFileWriter = testFileWriter;
     _fileHandler    = fileHandler;
 }
예제 #6
0
 // Methods
 public SuiteBuilder(ITemplates templates, ITestFileReader reader, ITestFileReader sourceReader)
 {
     this.templates    = templates;
     this.reader       = reader;
     this.sourceReader = sourceReader;
 }
예제 #7
0
 public ExcludeTestFileReader([NotNullOrEmpty] string excludePhrase, [NotNull] ITestFileReader adaptee)
     : base(adaptee)
 {
     this.excludePhrase = excludePhrase;
 }
예제 #8
0
        public bool Init(string path, string resourcePath)
        {
            timeStamp = DateTime.Now;

            DataStore.Initialize();

            _testFileReader = new TestFileReader(_fileService);

            Dictionary <string, string> testVariables = new Dictionary <string, string>();

            // read the resource file, if given
            if (String.IsNullOrEmpty(resourcePath) == false)
            {
                _testFileReader.LoadFile(resourcePath);
                testVariables = _testFileReader.GetVariables();
            }


            _testFileReader.LoadFile(path);
            _assembly     = Assembly.Load(_testFileReader.GetLibraryName());
            testVariables = testVariables.Concat(_testFileReader.GetVariables()).ToDictionary(x => x.Key, x => x.Value);
            _setups       = _testFileReader.GetSetup();
            _testSteps    = _testFileReader.GetTestSteps();
            _teardowns    = _testFileReader.GetTeardown();
            _customSteps  = _testFileReader.GetKeywords();
            _dataSets     = _testFileReader.GetDataSets();

            // insert the variables into the datastore to be accessed by steps
            foreach (var pair in testVariables)
            {
                var converted = ConvertVariableTokensToValues(pair.Value);
                DataStore.Add(pair.Key, converted);
            }


            // confirm all the required steps are defined
            var allSteps = GetAvailableTestSteps();

            allSteps.AddRange(_customSteps.Select(k => k.Keyword));
            allSteps = allSteps.Select(s => Regex.Replace(s, inlineParameterRegex, "'*'")).ToList();

            var missingSteps = _setups.Select(t =>
            {
                return(new TestStep()
                {
                    Keyword = Regex.Replace(t.Keyword, inlineParameterRegex, "'*'")
                });
            }).Where(s => allSteps.Contains(s.Keyword) == false).ToList();

            missingSteps.AddRange(_teardowns.Select(t =>
            {
                return(new TestStep()
                {
                    Keyword = Regex.Replace(t.Keyword, inlineParameterRegex, "'*'")
                });
            }).Where(s => allSteps.Contains(s.Keyword) == false).ToList());

            missingSteps.AddRange(_testSteps.Select(t =>
            {
                return(new TestStep()
                {
                    Keyword = Regex.Replace(t.Keyword, inlineParameterRegex, "'*'")
                });
            }).Where(s => allSteps.Contains(s.Keyword) == false).ToList());

            if (missingSteps.Count > 0)
            {
                Console.WriteLine("Unable to exeucte the test case.");
                Console.WriteLine("The following steps do not have definintions:\n" + string.Join("\n", missingSteps.Select(s => s.Keyword)));

                return(false);
            }


            return(true);
        }
예제 #9
0
 public AbstractTestFileReader([NotNull] ITestFileReader adaptee)
 {
     this.adaptee = adaptee;
 }