Esempio n. 1
0
        // Return a Bitmap with the edge selected by the user
        public Bitmap ApplyEdge(Bitmap selectedSource, IInterfaceEdge iEdge)
        {
            // Bitmap which store the result with the applied edge
            Bitmap bitmapApplyEdge = null;

            try
            {
                // Detect the name of the Edge selected
                switch (iEdge.GetEdgeName())
                {
                // None : The user don't want any edge on the bitmap. Get the original bitmap
                case "None":
                    bitmapApplyEdge = selectedSource;
                    break;

                // Prewitt : apply the Prewitt edge on the bitmap
                case "Prewitt":
                    bitmapApplyEdge = iEdge.PrewittEdge(selectedSource);
                    break;

                // Kirsch : apply the Kirsch edge on the bitmap
                case "Kirsch":
                    bitmapApplyEdge = iEdge.KirschEdge(selectedSource);
                    break;
                }
                return(bitmapApplyEdge);
            }
            catch (Exception e)
            {
                // If there is any exception, return null
                Console.WriteLine(e);
                return(null);;
            }
        }
Esempio n. 2
0
        public void TestEdge_GetSetEdgeName()
        {
            // Substitute for the interface Edge
            var edgeSub = Substitute.For <IInterfaceEdge>();

            // Define a new name
            string newName = "Prewitt";

            // Give the new name for the substitute
            edgeSub.GetEdgeName().Returns <string>(newName);

            // Set Edge with the new name
            iEdge.SetEdgeName(newName);

            // Check if the names are the same
            Assert.AreEqual(iEdge.GetEdgeName(), edgeSub.GetEdgeName());
        }