Beispiel #1
0
        public void IsValidFileName_GoodExtensionUppercase_ReturnsTrue()
        {
            LogAnalyzer analyzer = new LogAnalyzer();
            bool        result   = analyzer.IsValidLogFileName("filewithbadextension.SLF");

            Assert.True(result);
        }
Beispiel #2
0
        //NUnit requires test methods to be public, to be void, and to accept no parameters at the most basic configuration
        //Function name: [UnitOfWorkName]_[ScenarioUnderTest]_[ExpectedBehavior]
        public void IsValidFileName_BadExtension_ReturnsFalse()
        {
            LogAnalyzer analyzer = new LogAnalyzer();
            //rule: only extension with .SLF then return true
            bool result = analyzer.IsValidLogFileName("filewithbadextension.foo");

            Assert.False(result);
        }
        public void IsValidFileName_validFile_ReturnsTrue()
        {
            //arrange
            LogAnalyzer analyzer = new LogAnalyzer();
            //act
            bool result = analyzer.IsValidLogFileName("whatever.slf");

            //assert
            Assert.IsTrue(result, "filename should be valid!");
        }
        public void IsValidFileName_NameShorterThan6CharsButSupportedExtension_ReturnsFalse()
        {
            StubExtensionManager myFakeManager = new StubExtensionManager();

            myFakeManager.ShouldExtensionBeValid = true;

            //create analyzer and inject stub
            var log = new LogAnalyzer(myFakeManager);

            //Assert logic assuming extension is supported

            bool result = log.IsValidLogFileName("short.ext");

            Assert.IsFalse(result, "File name with less than 5 chars should have failed the method, even if the extension is supported");
        }