コード例 #1
0
        public void ValidateTAFFFileErrors_ThirdErrorDetected_ReturnsTrue()
        {
            // Arrange.
            // Getting the TaskAllocation object
            PT1.TaskAllocations taskAllocations = new TaskAllocations();

            // Getting the filelines to be passed to the Validate method
            string pathOfFile  = @"Programming Task 1 - Data Files\PT1 - Test4.taff";
            string currentPath = Directory.GetCurrentDirectory();

            Console.WriteLine("Current Path: " + currentPath);
            Console.WriteLine("Path of File: " + pathOfFile);

            Regex pathRegex = new Regex("bin.*");

            string rootPath = pathRegex.Replace(currentPath, "");

            Console.WriteLine("Retrieved root path: " + rootPath);

            pathOfFile = rootPath + pathOfFile;
            Console.WriteLine("Retrieved file path: " + pathOfFile);

            // storing the fillines in a string array
            taskAllocations.StoreTAFFLines(pathOfFile);

            string[] filelines = taskAllocations.getTAFFFileLines();

            // expected error
            string expectedError = "ID=RICE";

            Console.WriteLine("Expected Error: " + expectedError);

            // Validating the file, if errors are found they are stored in the list
            taskAllocations.ValidateTAFFFile(filelines);

            // Act.
            bool errorFound = taskAllocations.ValidateTAFFFileErrors(expectedError);

            // Assert.
            Assert.IsTrue(errorFound, "Expected error " + expectedError + " not found");
        }
コード例 #2
0
ファイル: UnitTest4.cs プロジェクト: idhant/SIT323-
        public void ValidateTAFFFile_ThirdFile_ReturnsTrue()
        {
            // Arange.
            // Getting the TaskAllocation object
            PT1.TaskAllocations taskAllocations = new TaskAllocations();

            // Getting the filelines to be passed to the Validate method
            // Navigating to the path of the file store in the test project folder.
            string pathOfFile  = @"Programming Task 1 - Data Files\PT1 - Test3.taff";
            string currentPath = Directory.GetCurrentDirectory();

            Console.WriteLine("Current Path: " + currentPath);
            Console.WriteLine("Path of File: " + pathOfFile);

            Regex pathRegex = new Regex("bin.*");

            string rootPath = pathRegex.Replace(currentPath, "");

            Console.WriteLine("Retrieved root path: " + rootPath);

            pathOfFile = rootPath + pathOfFile;
            Console.WriteLine("Retrieved file path: " + pathOfFile);

            // storing the fillines in a string array
            taskAllocations.StoreTAFFLines(pathOfFile);

            string[] filelines = taskAllocations.getTAFFFileLines();

            // the expected result
            bool expectedResult = true;

            // Act.
            bool actualResult = taskAllocations.ValidateTAFFFile(filelines);

            // Assert.
            Assert.AreEqual(expectedResult, actualResult, "The actual value doesn`t match the expected value");
        }