示例#1
0
        IsValidFileName_WhenCalled_ChangesWasLastFileNameValid()
        {
            LogAnalyzer la = new LogAnalyzer();

            la.IsValidLogFileNameee("badname.slf");
            Assert.True(la.WasLastFileNameValid);
        }
示例#2
0
        public void IsValidFileName_EmptyFileName_Throws() //s62
        {
            LogAnalyzer la = new LogAnalyzer();
            var         ex = Assert.Throws <ArgumentException>(() => la.IsValidLogFileNameee(""));

            StringAssert.Contains("nale¿y podaæ nazwê pliku", ex.Message);
        }
示例#3
0
        public void IsValidLogFileName_GoodExtensionUppercase_ReturnsTrue(string file, bool expected)
        {
            LogAnalyzer analyzer = new LogAnalyzer();
            bool        result   = analyzer.IsValidLogFileNameee(file);

            Assert.AreEqual(expected, result);
        }
示例#4
0
        public void IsValidLogFileName_GoodExtensionUppercase_ReturnsTrue(string file)
        {
            LogAnalyzer analyzer = new LogAnalyzer();
            bool        result   = analyzer.IsValidLogFileNameee(file);

            Assert.True(result);
        }
示例#5
0
        public void IsValidLogFileName_BadExtension_ReturnsFalse()
        {
            LogAnalyzer analyzer = new LogAnalyzer();
            bool        result   = analyzer.IsValidLogFileNameee("test.txt");

            Assert.False(result);
        }
示例#6
0
        [Category("Szybkie testy")] //s65
        public void IsValidLogFileName_GoodExtensionLowercase_ReturnsTrue()
        {
            LogAnalyzer analyzer = new LogAnalyzer();
            bool        result   = analyzer
                                   .IsValidLogFileNameee("filewithgoodextension.slf");

            Assert.True(result);
        }
示例#7
0
        IsValidFileName_WhenCalled_ChangesWasLastFileNameValid(string file,
                                                               bool expected)
        {
            LogAnalyzer la = MakeAnalyzer();

            la.IsValidLogFileNameee(file);
            Assert.AreEqual(expected, la.WasLastFileNameValid);
        }
示例#8
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_ExtManagerThrowsException_ReturnsFalse()
        {
            FakeExtensionManager myFakeManager = new FakeExtensionManager();

            myFakeManager.WillThrow = new Exception("to jest sztuczny wyj¹tek");
            LogAnalyzer log    = new LogAnalyzer(myFakeManager);
            bool        result = log.IsValidLogFileNameee("anything.anyextension");

            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 Analyze_TooShortFileName_CallsWebService()
        {
            var    mockService      = new MockService();
            var    log              = new LogAnalyzer(mockService);
            string tooShortFileName = "abc.ext";

            log.Analyze(tooShortFileName);

            Assert.AreEqual("Filename too short : abc.ext", mockService.LastError);
        }
        public void IsValidFileName_NameSupportedExtension_ReturnsTrue()
        {
            FakeExtensionManager myFakeManager = new FakeExtensionManager(); //Przes³anie namiastki

            myFakeManager.WillBeValid = true;                                //konfiguracja namiastki która zwraca true
            LogAnalyzer log    = new LogAnalyzer(myFakeManager);
            bool        result = log.IsValidLogFileNameee("short.ext");

            Assert.True(result);
        }
示例#13
0
        public void IsValidFileName_SupportedExtension_ReturnsTrue()
        {
            FakeExtensionManager myFakeManager = new FakeExtensionManager();
            //stworzenie analizatora i wstrzykniêcie namiastki
            LogAnalyzer             log     = new LogAnalyzer();
            ExtensionManagerFactory manager = new ExtensionManagerFactory();

            manager.SetManager(myFakeManager);
            //asercja logiki przy za³o¿eniu, ¿e rozszerzenie jest obs³ugiwane
            //...
        }
        public void Analyze_TooShortFileName_CallsWebService()
        {
            FakeWebService mockService      = new FakeWebService();
            LogAnalyzer    log              = new LogAnalyzer(mockService);
            string         tooShortFileName = "abc.ext";

            log.Analyze(tooShortFileName);
            //Zauwa¿my, ¿e asercja dotyczy obiektu-makiety, a nie klasy LogAnalyzer.
            //To dlatego, ¿e testujemy interakcje miêdzy klas¹ LogAnalyzer a us³ug¹ sieciow¹.
            StringAssert.Contains("Nazwa pliku jest zbyt krótka:abc.ext", mockService.LastError);
        }
        public void Analyze_TooShortFileName_CallLogger()
        {
            //Utworzenie obiektu-makiety,
            //wzglêdem którego pod koniec
            //testu wykonamy asercjê
            ILogger     logger   = Substitute.For <ILogger>();
            LogAnalyzer analyzer = new LogAnalyzer(logger);

            analyzer.Analyze("a.txt"); //metoda LogAnalyzer
            //Okreœlenie oczekiwania
            //z wykorzystaniem API
            //frameworka NSub
            logger.Received().LogError("Nazwa pliku jest za krótka: a.txt");
        }
        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");
        }
示例#17
0
 public void Setup()
 {
     analyzer = new LogAnalyzer();
 }
 public void TearDown()
 {
     m_analyzer = null;
 }