コード例 #1
0
        public void TestFileReader_LoadsFileWithLibraryName_ReturnsLibraryName()
        {
            TestFileReader testReader = new TestFileReader(fileService);

            testReader.LoadFile("my test");
            testReader.GetLibraryName().Should().Be("BadgerTests.dll");
        }
コード例 #2
0
        public void TestFileReader_LoadsFileWithoutLibraryName_ReturnsNullLibraryName()
        {
            fileService.GetLines("my test").Returns(new List <string>()
            {
                "*** Settings ***",
                "Libary  BadgerTests.dll"
            });
            TestFileReader testReader = new TestFileReader(fileService);

            testReader.LoadFile("my test");

            testReader.GetLibraryName().Should().BeNull();
        }
コード例 #3
0
        public void ViewOnFormLoad(object sender, EventArgs e)
        {
            _view.SaveEnabled    = false;
            _view.AddStepEnabled = false;
            _view.ClearTreeNodes();
            // is there a file path?  if yes, get the library name and load it
            if (!string.IsNullOrEmpty(FilePath))
            {
                var reader = new TestFileReader(_fileService);
                reader.LoadFile(FilePath);
                LibraryName = reader.GetLibraryName();

                _view.TestCaseLines = _fileService.GetLines(FilePath).ToArray();
                _view.SaveAsEnabled = true;
            }
            else
            {
                _fileBrowser.InitialDirectory = Environment.CurrentDirectory;
                if (_fileBrowser.ShowDialog())
                {
                    LibraryName = System.IO.Path.GetFileNameWithoutExtension(_fileBrowser.FileName);
                }
                else
                {
                    //_view.Close();
                    _view.Result = DialogResult.Cancel;
                }
                _view.TestCaseLines = new string[] { };
                _view.SaveAsEnabled = false;
            }
            SetTitle();

            if (String.IsNullOrEmpty(LibraryName) == false && CurrentLibrary != LibraryName)
            {
                // need to load new step list
                CurrentAssembly = Assembly.Load(LibraryName);
                CurrentLibrary  = LibraryName;
                StepClasses     = CurrentAssembly.GetTypes().Where(t => Attribute.IsDefined(t, typeof(StepsAttribute))).ToList();
            }

            // for the descriptions of the test steps
            LoadXml();
            BuildTestStepTree();

            _view.SaveEnabled = false;
        }