예제 #1
0
 public MementoEventArgs(string mementoName, string pluginKey, string previousMementoname = "", getMemento_Delegate getMemDel = null, Memento memento = null)
 {
     this.mementoName = mementoName;
     this.pluginKey = pluginKey;
     this.getMemDel = getMemDel;
     this.memento = memento;
     this.previousMementoName = previousMementoname;
 }
예제 #2
0
 public void mementoTest()
 {
     VM_Welcome_Accessor welcome = new VM_Welcome_Accessor();
     ArrayList state = new ArrayList();
     for (int i = 0; i < 17; i++)
     {
         state.Add(i.ToString());
     }
     Memento mem = new Memento("testmem", state);
     welcome.setMemento(mem);
     ArrayList projectList = (ArrayList)welcome.getMemento().state;
     Assert.AreEqual(15, projectList.Count);
     // if project list contains more than 15 projects,
     // first in first out is done until project list contains 15
     for (int i = 0; i < 15; i++)
     {
         Assert.AreEqual((i+2).ToString(), projectList[i]);
     }
 }
예제 #3
0
 public static void MyClassInitialize(TestContext testContext)
 {
     Invert inv = new Invert();
     testMemento = new Memento("Invert", inv);
     testBitmap = new Bitmap(100, 100);
     for (int height = 0; height < testBitmap.Height; height++)
     {
         for (int width = 0; width < testBitmap.Width; width++)
         {
             testBitmap.SetPixel(width, height, Color.White);
             width++;
             testBitmap.SetPixel(width, height, Color.Black);
             width++;
             testBitmap.SetPixel(width, height, Color.Red);
             width++;
             testBitmap.SetPixel(width, height, Color.Green);
             width++;
             testBitmap.SetPixel(width, height, Color.Blue);
         }
     }
     processedBitmap = inv.process(testBitmap);
 }
예제 #4
0
 public static void MyClassInitialize(TestContext testContext)
 {
     NoiseGenerator noiGen = new NoiseGenerator();
     original = noiGen.getMemento();
     testBitmap = new Bitmap(testPixel, testPixel);
     for (int height = 0; height < testBitmap.Height; height++)
     {
         for (int width = 0; width < testBitmap.Width; width++)
         {
             testBitmap.SetPixel(width, height, Color.White);
             width++;
             testBitmap.SetPixel(width, height, Color.Black);
             width++;
             testBitmap.SetPixel(width, height, Color.Red);
             width++;
             testBitmap.SetPixel(width, height, Color.Green);
             width++;
             testBitmap.SetPixel(width, height, Color.Blue);
         }
     }
     testNoise = new Memento("test", 5.1F);
 }
예제 #5
0
파일: MacroTest.cs 프로젝트: PSE-2012/MMWTV
        public void getMementoTest()
        {
            Macro_Accessor target = new Macro_Accessor();

            string mementoname = "setmementotestmemento";
            MacroEntry macroentry = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testMemento");
            MacroEntry subentry = new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testMemento2");
            macroentry.macroEntries.Add(subentry);
            Memento memento = new Memento(mementoname, macroentry);
            target.setMemento(memento);

            Memento actual;
            actual = target.getMemento();
            Assert.IsNotNull(actual, "Memento not returned.");
            Assert.AreEqual(mementoname, actual.name);
            Assert.IsNotNull(actual.state, "Memento is empty");
            Assert.AreEqual(subentry, ((MacroEntry)actual.state).macroEntries[0]);
        }
예제 #6
0
        /// <summary>
        /// Returns a Memento with the current state of the Object.
        /// </summary>
        public Oqat.PublicRessources.Model.Memento getMemento()
        {
            double[] colorValues= new double[3];
            colorValues[0] = redValue;
            colorValues[1] = greenValue;
            colorValues[2] = blueValue;
            Memento mem = new Memento(this.namePlugin, colorValues);

            return mem;
        }
예제 #7
0
        public void writeMementoTest_fileReadonly()
        {
            Caretaker target = Caretaker_Accessor.caretaker;

            string fileName = testfolder + "TestMementoFile.mem";
            Memento expected = new Memento("TestMemento", 42);
            expected.mementoPath = fileName;

            FileStream fs = File.Create(fileName);
            fs.WriteByte(1);
            fs.Close();
            FileInfo fInfo = new FileInfo(fileName);
            fInfo.IsReadOnly = true;

            target.writeMemento(expected);

            fInfo.IsReadOnly = false;
            FileStream fsr = File.Open(fileName, FileMode.Open);
            Assert.IsTrue((fsr.Length == 1 && fsr.ReadByte() == 1), "Readonly file was changed.");
            fsr.Close();
            //Exception is thrown, caught and passed to OqatErrorConsole
        }
예제 #8
0
파일: Caretaker.cs 프로젝트: PSE-2012/MMWTV
 /// <summary>
 /// Saves newly created Memento to the hard disk drive.
 /// /// <param name="objectToSerialize">The Memento</param> 
 /// </summary>
 public virtual void writeMemento(Memento objectToSerialize)
 {
     try
     {
         lock (writeDisk)
         {
             using(Stream stream = File.Open(objectToSerialize.mementoPath, FileMode.Create, FileAccess.Write, FileShare.None))
             {
                 BinaryFormatter bFormatter = new BinaryFormatter();
                 bFormatter.Serialize(stream, objectToSerialize);
             }
         }
     }
     catch (Exception exc)
     {
         PluginManager.pluginManager.raiseEvent(EventType.failure, new ErrorEventArgs(exc));
     }
 }
예제 #9
0
 /// <summary>
 /// Setter for properties (recoverd from disk by the Caretaker, passed by the PluginManager)
 /// </summary>
 /// <param name="memento">Properties to set.</param>
 /// <remarks>
 /// This is only a stub as VideoHandlers are not needed to keep their settings. 
 /// (Settings are rather saved with the Video object and its VideoInfo)
 /// </remarks>
 public void setMemento(Memento memento)
 {
 }
예제 #10
0
파일: PSNRTest.cs 프로젝트: PSE-2012/MMWTV
 public void getMementoTest()
 {
     PSNR target = new PSNR();
     Memento expected = new Memento("testMemento", target);
     Memento actual;
     actual = target.getMemento();
     Assert.AreEqual(expected.state, actual.state);
 }
예제 #11
0
파일: MSETest.cs 프로젝트: PSE-2012/MMWTV
 public void setMementoTest_notInt()
 {
     MSE target = new MSE();
     List<Memento> memList = new List<Memento>();
     Memento memento = new Memento("MEMLIST", memList);
     target.setMemento(memento);
 }
예제 #12
0
파일: MSETest.cs 프로젝트: PSE-2012/MMWTV
 public void getMementoTest()
 {
     MSE target = new MSE();
     Memento expected = new Memento("MSE", 0);
     Memento actual;
     actual = target.getMemento();
     Assert.AreEqual(expected.state, actual.state);
     Assert.AreEqual(expected.name, actual.name);
 }
예제 #13
0
파일: MSETest.cs 프로젝트: PSE-2012/MMWTV
 public void setMementoTest()
 {
     MSE_Accessor target = new MSE_Accessor();
     Memento memento = new Memento("MSE", 2);
     target.setMemento(memento);
     Assert.AreEqual(target.getMemento().state, 2, "propertiesView Radio Button could not be set.");
 }
예제 #14
0
파일: Macro.cs 프로젝트: PSE-2012/MMWTV
        public Memento getMemento()
        {
            Memento memToReturn;
            if (originallTlMacroName.Equals(rootEntry.mementoName))
                originallTlMacroName = "";

            MacroEntry rootEntryCopy = new MacroEntry(rootEntry.pluginName, rootEntry.type, rootEntry.mementoName);

            rootEntryCopy.startFrameRelative = rootEntry.startFrameRelative;
            rootEntryCopy.endFrameRelative = rootEntry.endFrameRelative;
            rootEntryCopy.path = rootEntry.path;

            doDeepCopy(rootEntry, ref rootEntryCopy);
            if (rootEntryCopy.mementoName.Equals(""))
                memToReturn = new Memento(rootEntryCopy.mementoName, new object());
            else if (rootEntryCopy.macroEntries.Count > 0)
                memToReturn = new Memento(rootEntryCopy.mementoName, rootEntryCopy as IMacroEntry);
            else
                memToReturn = new Memento(rootEntryCopy.mementoName, null);

            return memToReturn;
        }
예제 #15
0
        public void writeMementoTest_noFolder()
        {
            Caretaker target = Caretaker_Accessor.caretaker;

            string fileName = testfolder + "allNewOqatTestingFolder\\" + "TestMementoFile.mem";
            Memento expected = new Memento("TestMemento", 42);
            expected.mementoPath = fileName;

            target.writeMemento(expected);

            Assert.IsFalse(File.Exists(fileName), "New folder was created for memento. This might be unwanted behavior or a security risk.");
            //exception is thrown, caught and passed to OQAT ErrorConsole
        }
예제 #16
0
        public static void MyClassInitialize(TestContext testContext)
        {
            RelativeColor relCol = new RelativeColor();
            testBitmap = new Bitmap(testPixel, testPixel);
            for (int height = 0; height < testBitmap.Height; height++)
            {
                for (int width = 0; width < testBitmap.Width; width++)
                {
                    testBitmap.SetPixel(width, height, Color.White);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Black);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Red);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Green);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Blue);
                }
            }

            //create greyscale
            double[] newColorValues = new double[3];
            for (int i = 0; i < newColorValues.GetLength(0); i++)
            {
                newColorValues[i] = 2;
            }
            doubleColor = new Memento("2xColor", newColorValues);

            //get greyscaled Bitmap
            original = relCol.getMemento();
            relCol.setMemento(doubleColor);
            processedBitmap = relCol.process(testBitmap);
            relCol.setMemento(original);
        }
예제 #17
0
파일: MacroTest.cs 프로젝트: PSE-2012/MMWTV
        public void setMementoTest_nullstate()
        {
            Macro_Accessor target = new Macro_Accessor();

            string mementoname = "testmemento";
            Memento memento = new Memento(mementoname, null);

            target.setMemento(memento);

            Assert.AreNotEqual<string>(mementoname, target.rootEntry.mementoName, "The invalid memento was partly loaded.");
            Assert.IsNotNull(target.rootEntry.macroEntries, "Macro was set to null.");
        }
예제 #18
0
파일: MSETest.cs 프로젝트: PSE-2012/MMWTV
        public void setMementoTest_range()
        {
            MSE_Accessor target = new MSE_Accessor();
            Memento memento = new Memento("RANGE", -1);
            target.setMemento(memento);
            Assert.IsTrue((int)target.getMemento().state > -1, "Invailed Range for MSE. Range [0, 3]");

            memento = new Memento("RANGE", 4);
            target.setMemento(memento);
            Assert.IsTrue((int)target.getMemento().state < 4, "Invailed Range for MSE. Range [0, 3]");
        }
예제 #19
0
파일: MacroTest.cs 프로젝트: PSE-2012/MMWTV
        public void setMementoTest_ok()
        {
            Macro_Accessor target = new Macro_Accessor();

            string mementoname = "setmementotestmemento";
            string entrymementoname = "settestMemento";
            MacroEntry macroentry = new MacroEntry("testPlugin", PluginType.IMacro, entrymementoname);
            MacroEntry subentry = new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testMemento2");
            macroentry.macroEntries.Add(subentry);
            Memento memento = new Memento(mementoname, macroentry);

            target.setMemento(memento);

            Assert.AreEqual<string>(entrymementoname, target.rootEntry.mementoName, "The memento's state was not loaded.");
            Assert.AreEqual(subentry, macroentry.macroEntries[0]);
        }
예제 #20
0
 public void setMementoTest()
 {
     Convolution target = new Convolution();
     int[,] expectedMatrix = new int[6, 6];
     Memento memento = new Memento("Conv", new int[6, 6]);
     target.setMemento(memento);
     Assert.IsTrue(target.matrix is int[,], "Memento.state is not a Matrix.");
     int[,] actualMatrix = (int[,])target.getMemento().state;
     for (int dim1 = 0; dim1 < expectedMatrix.GetLength(0); dim1++)
     {
         for (int dim2 = 0; dim2 < expectedMatrix.GetLength(1); dim2++)
         {
             Assert.AreEqual(expectedMatrix[dim1, dim2], actualMatrix[dim1, dim2], "Matrix is not expected matrix.");
         }
     }
 }
예제 #21
0
 public void setMementoTest()
 {
     Player target = new Player();
     Memento memento = null;
     target.setMemento(memento);
     Memento expected = new Memento("dd", null, "dd");
     Memento actual;
     actual = target.getMemento();
     Assert.AreEqual(expected.name, actual.name);
     Assert.AreEqual(expected.state, actual.state);
     Assert.AreEqual(expected.mementoPath, actual.mementoPath);
 }
예제 #22
0
        public static void MyClassInitialize(TestContext testContext)
        {
            Greyscale conv = new Greyscale();
            testBitmap = new Bitmap(testPixel, testPixel);
            for (int height = 0; height < testBitmap.Height; height++)
            {
                for (int width = 0; width < testBitmap.Width; width++)
                {
                    testBitmap.SetPixel(width, height, Color.White);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Black);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Red);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Green);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Blue);
                }
            }

            //create greyscale
            double[] newColorValues = new double[3];
            for (int i = 0; i < newColorValues.GetLength(0); i++)
            {
                newColorValues[i] = 1;
            }
            fullGrey = new Memento("Blur", newColorValues);

            //get greyscaled Bitmap
            original = conv.getMemento();
            conv.setMemento(fullGrey);
            processedBitmap = conv.process(testBitmap);
            conv.setMemento(original);
        }
예제 #23
0
        public void getMementoTest()
        {
            Diagramm target = new Diagramm();
            Memento expected = new Memento("Diagram_settings", null);
            Memento actual;
            actual = target.getMemento();

            Assert.IsNotNull(actual, "Memento could not be loaded");
            Assert.AreEqual(expected.name, actual.name);
            Assert.AreEqual(expected.mementoPath, actual.mementoPath);
            Assert.AreEqual(expected.state, actual.state, "Has Memento for PP_Diagram been implemented? Adapt testcode!");
        }
예제 #24
0
 public void setMementoTest_notMemento()
 {
     Invert target = new Invert();
     List<Memento> memList = new List<Memento>();
     Memento memento = new Memento("Invert", memList);
     target.setMemento(memento);
     Assert.IsTrue(target.getMemento().state is Invert, "Invert doesn't care about Memento's, it does not need any.");
 }
예제 #25
0
        public static void MyClassInitialize(TestContext testContext)
        {
            Convolution conv = new Convolution();
            testBitmap = new Bitmap(testPixel, testPixel);
            for (int height = 0; height < testBitmap.Height; height++)
            {
                for (int width = 0; width < testBitmap.Width; width++)
                {
                    testBitmap.SetPixel(width, height, Color.White);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Black);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Red);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Green);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Blue);
                }
            }

            //create blur matrix
            int square = 3;
            matrix = new int[square, square];
            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int j = 0; j < matrix.GetLength(1); j++)
                {
                    matrix[i, j] = 1;
                }
            }
            blur = new Memento("Blur", matrix);
            //get blured Bitmap
            original = conv.getMemento();
            conv.setMemento(blur);
            processedBitmap = conv.process(testBitmap);
            conv.setMemento(original);
        }
예제 #26
0
        public void getMementoTest_MementoWrongExtension()
        {
            Caretaker target = Caretaker_Accessor.caretaker;

            string fileName = testfolder+"PF_Convolution.nomem";
            Memento expected = new Memento("TestMemento", 42);
            expected.mementoPath = fileName;

            target.writeMemento(expected);

            Memento actual;
            actual = target.getMemento(fileName);

            Assert.IsNotNull(actual, "The memento could not be read.");
            Assert.AreEqual(expected.name, actual.name);
            Assert.AreEqual(expected.state, actual.state);
            Assert.AreEqual(expected.mementoPath, actual.mementoPath);
        }
예제 #27
0
파일: PSNR.cs 프로젝트: PSE-2012/MMWTV
 /// <summary>
 /// not necesarry method here
 /// </summary>
 public Oqat.PublicRessources.Model.Memento getMemento()
 {
     Memento mem = new Memento(this.namePlugin, this);
     return mem;
 }
예제 #28
0
 /// <summary>
 /// Returns the current state as a Memento Object
 /// </summary>
 private Memento getMemento()
 {
     int listboxLength = 15;
     if (projects.Count > listboxLength)
     {
         this.projects.RemoveRange(0, projects.Count - listboxLength);
     }
     Memento mem = new Memento("VM_Welcome.mem", this.projects, Directory.GetCurrentDirectory() + "/VM_Welcome.mem");
     return mem;
 }
예제 #29
0
 /// <summary>
 /// Sets mem as current state
 /// </summary>
 private void setMemento(Memento mem)
 {
     if (mem != null)
     {
         var obj = (ArrayList)mem.state;
         if (obj != null)
         {
             this.projects = obj;
         }
     }
 }
예제 #30
0
        public void writeMementoTest_fileExists()
        {
            Caretaker target = Caretaker_Accessor.caretaker;

            string fileName = testfolder + "TestMementoFile.mem";
            Memento expected = new Memento("TestMemento", 42);
            expected.mementoPath = fileName;

            FileStream fs = File.Create(fileName);
            fs.Close();

            //expecting to overwrite file
            target.writeMemento(expected);

            Memento actual;
            actual = target.getMemento(fileName);

            Assert.IsNotNull(actual, "The memento could not be read.");
            Assert.AreEqual(expected.name, actual.name);
            Assert.AreEqual(expected.state, actual.state);
            Assert.AreEqual(expected.mementoPath, actual.mementoPath);
        }