Esempio n. 1
0
        public void IsValidLogFileNameShouldReturnTrueWhenExtensionManagerValidatesExtension()
        {
            // Arrange
            const bool ExpectedResult = true;
            var        stub           = new Mock <IExtensionManager>();

            stub.Setup(m => m.IsValid(It.IsAny <string>()))
            .Returns(ExpectedResult);

            LogAnalyzer sut = new LogAnalyzerBuilder()
                              .WithExtensionManager(stub.Object)
                              .Build();

            // Act
            var result = sut.IsValidLogFileName("file.log");

            // Assert
            Assert.That(result, Is.EqualTo(ExpectedResult));
        }
Esempio n. 2
0
        public void IsValidLogFileNameShouldThrowExceptionWhenFilenameIsNullOrEmptyWithFluent(string filename)
        {
            // Arrange
            const string ExpectedResult = "filename has to be provided";

            var stub = new Mock <IExtensionManager>();

            stub.Setup(m => m.IsValid(It.Is <string>(s => s == filename)))
            .Throws(new ArgumentException(ExpectedResult));

            LogAnalyzer sut = new LogAnalyzerBuilder()
                              .WithExtensionManager(stub.Object)
                              .Build();

            // Act
            TestDelegate methodToTest = () => sut.IsValidLogFileName(filename);

            // Assert
            Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.Contains(ExpectedResult), methodToTest);
        }