Esempio n. 1
0
 public virtual bool Load(Stream stream)
 {
     if (!ProblemSpecification.Load(stream))
     {
         return(false);
     }
     Dispatcher.BeginInvoke((Action)(() =>
     {
         if (ProblemSpecification.DocumentData != null)
         {
             Document = DocumentHelper.BytesToXpsDocument(ProblemSpecification.DocumentData);
         }
         else
         {
             Document = null;
         }
         Name = ProblemSpecification.Name;
         State = ProblemState.NotTested;
         StateText = "Not Tested";
         MemoryLimit = ProblemSpecification.MemoryLimit / 1024 / 1024;
         TimeLimit = ProblemSpecification.TimeLimit;
         IsDirty = false;
         IsEditing = false;
         IsNew = false;
     }));
     return(true);
 }
Esempio n. 2
0
        public void EqualityCompareProblemLoadingSavingTest()
        {
            EqualityCompareProblem ep = new EqualityCompareProblem();

            string[] testInput  = { "first input", "second input", "third input" };
            string[] testOutput = { "first output", "second output", "third output" };
            string   password   = "******";

            ep.Name = "Test Problem";
            var doc = DocumentHelper.LoadXpsData("Dummy Doucment.xps");

            ep.DocumentData = DocumentHelper.XpsDocumentToBytes(doc);
            Assert.IsTrue(ep.Initialize(testOutput, testInput, password));

            MemoryStream ms = new MemoryStream();

            Assert.IsTrue(ep.Save(ms));
            ms.Flush();
            ms.Close();
            ep = new EqualityCompareProblem();
            ms = new MemoryStream(ms.ToArray());
            Assert.IsTrue(ep.Load(ms));
            string[] o1 = ep.GetCorrectOutput(password);
            Assert.IsNotNull(o1);
            Assert.IsTrue(testOutput.Length == o1.Length);
            DocumentHelperTest.ShowDoucment(DocumentHelper.BytesToXpsDocument(ep.DocumentData));
            for (int i = 0; i < testOutput.Length; i++)
            {
                Assert.IsTrue(testOutput[i] == o1[i]);
            }
        }
        public void XpsDoucmentToolsTest()
        {
            string s   = Environment.CurrentDirectory;
            var    doc = DocumentHelper.LoadXpsData("Dummy Doucment.xps");

            Assert.IsNotNull(doc);
            ShowDoucment(doc);
            var docdata = DocumentHelper.XpsDocumentToBytes(doc);

            doc = DocumentHelper.BytesToXpsDocument(docdata);
            ShowDoucment(doc);
        }