public void CreateProcessTest()
        {
            var fpb  = new FetProcessBuilder();
            var proc = fpb.CreateProcess();

            Assert.IsInstanceOf <Process>(proc);
        }
        public void Setup()
        {
            // Can't mock sealed class process, so create a real instance here
            var fpb = new FetProcessBuilder(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib", "fet", "fet-cl"));

            fpb.SetInputFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testdata", "fet", "Italy", "2007", "difficult", "highschool-Ancona.fet"));

            _process = fpb.CreateProcess();
            _fpi     = new FetProcessFacadeExposer(_process, CancellationToken.None);
        }
        public void InvalidProcessStartProcessTest()
        {
            var fpb = new FetProcessBuilder();

            _process = fpb.CreateProcess();
            _fpi     = new FetProcessFacadeExposer(_process, CancellationToken.None);

            var task = _fpi.StartProcess();

            // Assertions
            var ex = Assert.Throws <AggregateException>(() => task.Wait());

            Assert.IsInstanceOf <InvalidOperationException>(ex.InnerException);
        }
        public void CheckProcessNonZeroExitCodeTest()
        {
            // Create process again with different arguments
            var fpb = new FetProcessBuilder(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib", "fet", "fet-cl"));

            // Invalid input file
            fpb.SetInputFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testdata", "fet", "invalid.xml"));

            var tempDir = Path.Combine(Path.GetTempPath(), "timetabling-tests");

            Directory.CreateDirectory(tempDir);
            fpb.SetOutputDir(tempDir);

            _process = fpb.CreateProcess();
            _fpi     = new FetProcessFacadeExposer(_process, CancellationToken.None);

            // Start process
            _fpi.StartProcess();
            var ex = Assert.Throws <AggregateException>(() => _fpi.TaskCompletionSource.Task.Wait());

            Assert.IsInstanceOf <InvalidOperationException>(ex.InnerException);
        }
        public void CheckProcessZeroExitCodeTest()
        {
            // Create process again with different arguments
            var fpb = new FetProcessBuilder(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib", "fet", "fet-cl"));

            // Hopwood runs usually very fast
            fpb.SetInputFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testdata", "fet", "United-Kingdom", "Hopwood", "Hopwood.fet"));

            var tempDir = Path.Combine(Path.GetTempPath(), "timetabling-tests");

            Directory.CreateDirectory(tempDir);
            fpb.SetOutputDir(tempDir);

            _process = fpb.CreateProcess();
            _fpi     = new FetProcessFacadeExposer(_process, CancellationToken.None);

            // Start process
            _fpi.StartProcess();

            var task = _fpi.TaskCompletionSource.Task;

            task.Wait();
        }