public void ThrowArgumentExceptionIfFromLineIsBiggerThanToLine() { const string filePath = @"F:\C#\PROJECTS\FilePartReader\test.txt"; const int fromLine = 4; const int toLine = 1; Assert.Throws <ArgumentException>(() => _filePartReader.Setup(filePath, fromLine, toLine)); }
public void Constructor_FileNotFound_ThrowsErrorMessage() { var filePath = "random.txt"; var fromLine = 1; var toLine = 3; var expectedMessage = "File not found."; var ex = Assert.Throws <FileNotFoundException>(() => _filePartReader.Setup(filePath, fromLine, toLine)); Assert.AreEqual(expectedMessage, ex.Message); }
public void TestSetUp() { FilePartReader = new FilePartReader(); FilePartReader.Setup(@"C:\Users\Gery\source\repos\AdvanceSI\DotNet\SI_Assignments\SI3Assignments\Test.txt", 1, 7); FileWordAnalyzer = new FileWordAnalyzer(FilePartReader); }
public void TestReadThrowsIOExceptionWhenFileNotFound() { // arrange FilePartReader filePartReader = new FilePartReader(); filePartReader.Setup("nonExistingFile", 1, 3); //assert Assert.Throws <FileNotFoundException>(() => filePartReader.Read()); }
public void TestSetupThrowsArgumentExceptionWhenToLineLessFromLine() { // arrange FilePartReader filePartReader = new FilePartReader(); int _fromLine = 1; int _toLine = 0; //assert Assert.Throws <ArgumentException>(() => filePartReader.Setup("testFile.txt", _fromLine, _toLine)); }
public void TestReadLinesGetSingleLineWhenFromLineAndToLineAreEqual() { // arrange FilePartReader filePartReader = new FilePartReader(); int fromLine = 1; int toLine = 1; filePartReader.Setup("d:\\test.txt", fromLine, toLine); String _expected = "first line of text"; // act String _actual = filePartReader.ReadLines(); // assert Assert.That(_actual, Is.EqualTo(_expected)); }
public void TestSetupGetFileLinesWhenSetupsIsSuccessful() { // arrange FilePartReader filePartReader = new FilePartReader(); int _fromLine = 1; int _toLine = 2; filePartReader.Setup("d:\\test.txt", _fromLine, _toLine); String _expected = "first line of text second line of ala"; // act String _actual = filePartReader.ReadLines(); // assert Assert.That(_actual, Is.EqualTo(_expected)); }
public void TestReadLinesGetEmptyStringWhenGivenFileIsEmpty() { // arrange FilePartReader filePartReader = new FilePartReader(); int fromLine = 1; int toLine = 1; filePartReader.Setup("d:\\emptyTestFile.txt", fromLine, toLine); String _expected = ""; // act String _actual = filePartReader.ReadLines(); // assert Assert.That(_actual, Is.EqualTo(_expected)); }
public void TestReadLinesGetContentToLastLineWhenToLineIsMoreThenLinesCountInFile() { // arrange FilePartReader filePartReader = new FilePartReader(); int fromLine = 1; int toLine = 5; filePartReader.Setup("d:\\test.txt", fromLine, toLine); String _expected = "first line of text second line of ala last of best radar"; // act String _actual = filePartReader.ReadLines(); // assert Assert.That(_actual, Is.EqualTo(_expected)); }
public void TestReadGetFileContentWhenReadFromExistingFile() { // arrange FilePartReader filePartReader = new FilePartReader(); int fromLine = 1; int toLine = 3; filePartReader.Setup("d:\\test.txt", fromLine, toLine); String _expected = "first line of text" + Environment.NewLine + "second line of ala" + Environment.NewLine + "last of best radar"; // act String _actual = filePartReader.Read(); // assert Assert.That(_actual, Is.EqualTo(_expected)); }
public void GetStringsWhichPalindromes_ContainsPalindromes_ReturnPalindromesAsList() { // Arrange var defaultPath = string.Empty; FilePartReader reader = new FilePartReader(); reader.Setup("test.txt", 1, 7); var analyzer = new FileWordAnalyzer(reader); var expected = new List <string>() { "kajak", "lol", "görög" }; // Act var palindromes = analyzer.GetStringsWhichPalindromes(); // Assert CollectionAssert.AreEqual(expected, palindromes); }
public void SetUp() { _filePartReader = new FilePartReader(); _filePartReader.Setup("test.txt", 1, 6); _fileWorldAnalyzer = new FileWordAnalyzer(_filePartReader); }
public void TestSetup() { sut = new FilePartReader(); sut.Setup(@"C:\Users\doram\OneDrive\Desktop\.NET module\C# questions.txt", 1, 3); }
public void Setup_FromLineBiggerThanToLine_HasNoReturn() { Assert.Throws <ArgumentException>(() => _filePartReader.Setup("test.txt", 5, 3)); }