public void TestMethod1() { //Arrange TaskAllocations test = new TaskAllocations("Test1.tan"); //Act TaskAllocations.TryParse("Test1.tan", out test); //Assert }
public void AllocationsTest() { //Arrange int expectedAllocations = 8; //Act TaskAllocations test = new TaskAllocations(test1FilePath); TaskAllocations.TryParse(test1FilePath, out test); int allocations = test.NumAllocations; //Assert Assert.AreEqual(expectedAllocations, allocations, "ALLOCATIONS is incorrect in Test1.tan"); }
public void ProcessorsTest() { //Arrange int expectedProcessors = 3; //Act TaskAllocations test = new TaskAllocations(test1FilePath); TaskAllocations.TryParse(test1FilePath, out test); int processors = test.Processors; //Assert Assert.AreEqual(expectedProcessors, processors, "PROCESSORS is incorrect in Test1.tan"); }
public void TasksTest() { //Arrange int expectedTasks = 5; //Act TaskAllocations test = new TaskAllocations(test1FilePath); TaskAllocations.TryParse(test1FilePath, out test); int tasks = test.Tasks; //Assert Assert.AreEqual(expectedTasks, tasks, "TASKS is incorrect in Test1.tan"); }
public void ConfigFileTest() { //Arrange string expectedConfigFile = "Test1.csv"; //Act TaskAllocations test = new TaskAllocations(test1FilePath); TaskAllocations.TryParse(test1FilePath, out test); string configFile = test.ConfigPath; //Assert Assert.AreEqual(expectedConfigFile, configFile, "CONFIGURATION path is incorrect in Test1.tan"); }
public void AllocationRuntimeTest1() { //Arrange string tanPath = "C:\\Users\\Tyson\\source\\repos\\SIT323Assignment1\\Files for Unit Testing\\Test1.tan"; string configPath = "C:\\Users\\Tyson\\source\\repos\\SIT323Assignment1\\Files for Unit Testing\\Test1.csv"; double expectedTime = 2.61; List <string> errors = new List <string>(); //Act TaskAllocations.TryParse(tanPath, out TaskAllocations aTaskAllocation); Configuration.TryParse(configPath, out Configuration aConfiguration); double actualtime = Math.Round(aTaskAllocation.SetOfAllocations[0].CalculateTime(aConfiguration, out errors), 2); //Assert Assert.AreEqual(expectedTime, actualtime); }
public void AllocationID2Test() { //Arrange int expectedID = 2; double[,] expectedMatrix1 = { { 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 1 }, { 0, 0, 1, 1, 0 } }; //Act TaskAllocations test = new TaskAllocations(test1FilePath); TaskAllocations.TryParse(test1FilePath, out test); int id = test.SetOfAllocations[1].ID; double[,] matrix = test.SetOfAllocations[1].AllocationMatrix; //Assert Assert.AreEqual(expectedID, id, "ALLOCATION-ID 2 has incorrect ID"); CollectionAssert.AreEqual(expectedMatrix1, matrix, "ALLOCATION-ID 2 is incorrect in Test1.tan"); }
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"); }
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"); }