public void IsValidFileName_NameSupportedExtension_ReturnTrue()
        {
            FakeExtensionManager fakeManager = new FakeExtensionManager();

            fakeManager.WillBeValid = true;
            ExtensionManagerFactory.SetManager(fakeManager);
            LogAnalyzer analyzer = new LogAnalyzer();
            bool        result   = analyzer.IsValidLogFileName("wtf.wtf");

            Assert.True(result);
        }
Example #2
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
            //...
        }
Example #3
0
        public void IsValidFileName_SupportedExtensionUsingFactoryClass_ReturnsTrue()
        {
            FakeExtensionManager myFakeManager = new FakeExtensionManager();

            myFakeManager.WillBeValid = true;

            ExtensionManagerFactory.SetManager(myFakeManager); //create Analyzer, di the stub
            LogAnalyzerCh3WithFactoryClass log = new LogAnalyzerCh3WithFactoryClass();
            bool result = log.IsValidLogFileName("short.ext");

            Assert.IsTrue(result);
        }
        ////////////////
        // Using Constructor Injection
        ////////////////
        private LogAnalyzer MakeAnalyzer(bool managerWillBevalid = true,
                                         Exception managerThrows = null)
        {
            FakeExtensionManager myFakeManager = new FakeExtensionManager();

            myFakeManager.WillBeValid = managerWillBevalid;
            myFakeManager.WillThrow   = managerThrows;

            ExtensionManagerFactory.SetManager(myFakeManager);

            return(new LogAnalyzer());
        }
Example #5
0
        public void IsValidFileName_NameSupportedExtension_RetuensTrue()
        {
            FakeExtensionManager fake =
                new FakeExtensionManager {
                WillBeValid = true
            };

            ExtensionManagerFactory.SetManager(fake);
            LogAnalyzer logAnalyzer = new LogAnalyzer();
            bool        isValid     = logAnalyzer.IsValidLogFileName("a.txt");

            Assert.IsTrue(isValid);
        }
        public void IsValidFileName_SupportedExtensionFactoryMethod_ReturnsTrue()
        {
            FakeExtensionManager myFakeManager =
                new FakeExtensionManager();

            myFakeManager.WillBeValid = true;

            ExtensionManagerFactory.SetManager(myFakeManager);
            FactoryPatternLogAnalyzer log =
                new FactoryPatternLogAnalyzer();
            bool result = log.IsValidLogFilename("anyfilename.htmlc");

            Assert.True(result);
        }
        public void IsValdFileName_NameShorterThan6CharsButSupportedExtension_ReturnsFalse()
        {
            StubExtensionManager myFakeManager = new StubExtensionManager();

            myFakeManager.ShouldExtensionBeValid = true;

            ExtensionManagerFactory.SetManager(myFakeManager);

            // Analyzer 생성 및 스텁 주입
            TestableLogAnalyzer log = new TestableLogAnalyzer();

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

            Assert.IsFalse(result, "지원되는 확장자라 하더라도 파일명이 다섯 글자 미만이면 안됨");
        }
Example #8
0
        public void IsValidFileName_NameShorterThan6CharsButSupportedExtension_RetunsFalse()
        {
            StubExtensionManager myFakeManager = new StubExtensionManager();

            myFakeManager.ShouldExtensionBeValid = true;

            ExtensionManagerFactory.SetManager(myFakeManager);

            // Analyzer 생성 및 스텁 주입
            LogAnalyzer log = new LogAnalyzer();

            // 확장자 지원 확인 로직에 대한 assert
            bool result = log.IsValidLogFileName("short.ext");

            Assert.IsFalse(result, "설사 지원하더라도 파일명이 다섯 글자 미만이면 안 됨");
        }
        public void IsValidFileName_SupportedExtension_ReturnsTrue()
        {
            //set up the stub to use, make sure it returns true
            var myFakeExtensionManager = new FakeExtensionManager {
                WillBeValid = true
            };

            // set stub into factory class for this test
            ExtensionManagerFactory.SetManager(myFakeExtensionManager);
            LogAnalyzer logAnalyzer = new LogAnalyzer();

            // Act
            bool result = logAnalyzer.IsValidLogFileName("validFileName.ext");

            // Assert
            Assert.True(result);
        }
 public void TearDown()
 {
     ExtensionManagerFactory.SetManager(null);
 }