示例#1
0
        static int Main(string[] args)
        {
            // Disable running on Windows 7 until IJW activation work is complete.
            if (Environment.OSVersion.Platform != PlatformID.Win32NT || TestLibrary.Utilities.IsWindows7)
            {
                return(100);
            }

            bool     success      = true;
            Assembly ijwNativeDll = Assembly.Load("IjwNativeCallingManagedDll");

            TestFramework.BeginTestCase("Call native method returning int");
            Type       testType     = ijwNativeDll.GetType("TestClass");
            object     testInstance = Activator.CreateInstance(testType);
            MethodInfo testMethod   = testType.GetMethod("ManagedEntryPoint");
            int        result       = (int)testMethod.Invoke(testInstance, null);

            if (result != 100)
            {
                TestFramework.LogError("IJW", "Incorrect result returned: " + result);
                success = false;
            }
            TestFramework.EndTestCase();

            return(success ? 100 : 99);
        }
        static int Main(string[] args)
        {
            // Disable running on Windows 7 until IJW activation work is complete.
            if (Environment.OSVersion.Platform != PlatformID.Win32NT || TestLibrary.Utilities.IsWindows7)
            {
                return(100);
            }

            bool success = true;

            // Load a fake mscoree.dll to avoid starting desktop
            LoadLibraryEx(Path.Combine(Environment.CurrentDirectory, "mscoree.dll"), IntPtr.Zero, 0);

            TestFramework.BeginScenario("Calling from managed to native IJW code");

            // Building with a reference to the IJW dll is difficult, so load via reflection instead
            TestFramework.BeginTestCase("Load IJW dll via reflection");
            Assembly ijwNativeDll = Assembly.Load("IjwNativeDll");

            TestFramework.EndTestCase();

            TestFramework.BeginTestCase("Call native method returning int");
            Type       testType     = ijwNativeDll.GetType("TestClass");
            object     testInstance = Activator.CreateInstance(testType);
            MethodInfo testMethod   = testType.GetMethod("ManagedEntryPoint");
            int        result       = (int)testMethod.Invoke(testInstance, null);

            if (result != 100)
            {
                TestFramework.LogError("IJW", "Incorrect result returned: " + result);
                success = false;
            }
            TestFramework.EndTestCase();

            TestFramework.BeginTestCase("Negative: Load IJW dll as byte array");
            byte[] ijwBytes = File.ReadAllBytes("IjwNativeDll.dll");
            try
            {
                Assembly.Load(ijwBytes);
                TestFramework.LogError("IJW", "Loading IJW dll as byte array should have thrown");
                success = false;
            }
            catch { }
            TestFramework.EndTestCase();

            TestFramework.BeginTestCase("Ensure .NET Framework was not loaded");
            IntPtr clrHandle = GetModuleHandle("mscoreei.dll");

            if (clrHandle != IntPtr.Zero)
            {
                TestFramework.LogError("IJW", ".NET Framework loaded by IJw module load");
                success = false;
            }
            TestFramework.EndTestCase();

            return(success ? 100 : 99);
        }
示例#3
0
    public static int Main(string[] args)
    {
        ArrayInit ai = new ArrayInit();

        TestFramework.BeginTestCase("Exception thrown in default ctor of a valuetype during Array.Initialize");
        if (ai.RunTests())
        {
            return(100);
        }
        else
        {
            return(0);
        }
    }
        static int Main(string[] args)
        {
            // Disable running on Windows 7 until IJW activation work is complete.
            if (Environment.OSVersion.Platform != PlatformID.Win32NT || TestLibrary.Utilities.IsWindows7)
            {
                return(100);
            }

            bool     success      = true;
            Assembly ijwNativeDll = IjwHelper.LoadIjwAssembly("IjwNativeDll");

            TestFramework.BeginTestCase("Call native method returning int");
            Type       testType     = ijwNativeDll.GetType("TestClass");
            object     testInstance = Activator.CreateInstance(testType);
            MethodInfo testMethod   = testType.GetMethod("ManagedEntryPoint");
            int        result       = (int)testMethod.Invoke(testInstance, null);

            if (result != 100)
            {
                TestFramework.LogError("IJW", "Incorrect result returned: " + result);
                success = false;
            }
            TestFramework.EndTestCase();

            TestFramework.BeginTestCase("Negative: Load IJW dll as byte array");
            byte[] ijwBytes = File.ReadAllBytes("IjwNativeDll.dll");
            try
            {
                Assembly.Load(ijwBytes);
                TestFramework.LogError("IJW", "Loading IJW dll as byte array should have thrown");
                success = false;
            }
            catch { }
            TestFramework.EndTestCase();

            TestFramework.BeginTestCase("Ensure .NET Framework was not loaded");
            IntPtr clrHandle = GetModuleHandle("mscoreei.dll");

            if (clrHandle != IntPtr.Zero)
            {
                TestFramework.LogError("IJW", ".NET Framework loaded by IJw module load");
                success = false;
            }
            TestFramework.EndTestCase();

            return(success ? 100 : 99);
        }
示例#5
0
    static int Main()
    {
        EncodingGetString test = new EncodingGetString();

        TestFramework.BeginTestCase("Encoding.GetString");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
    static int Main()
    {
        CompareInfoLastIndexOf test = new CompareInfoLastIndexOf();

        TestFramework.BeginTestCase("CompareInfo.LastIndexOf");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
示例#7
0
    static int Main()
    {
        StringJoin test = new StringJoin();

        TestFramework.BeginTestCase("String.Join");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
    static int Main()
    {
        CompareInfoIsSuffix test = new CompareInfoIsSuffix();

        TestFramework.BeginTestCase("CompareInfo.IsSuffix");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
示例#9
0
    static int Main()
    {
        ValueTypeEquals2 test = new ValueTypeEquals2();

        TestFramework.BeginTestCase("ValueType.Equals(Object,Object)");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
示例#10
0
    static int Main()
    {
        StringBuilderCapacity test = new StringBuilderCapacity();

        TestFramework.BeginTestCase("StringBuilder.Capacity");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
示例#11
0
    public static int Main(string[] args)
    {
        WeakReferenceCtor test = new WeakReferenceCtor();

        TestFramework.BeginTestCase("Testing WeakReference.Ctor (2)");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
示例#12
0
    static int Main()
    {
        EnumIsDefined test = new EnumIsDefined();

        TestFramework.BeginTestCase("Enum.IsDefined(enumType,value)");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
示例#13
0
    static int Main()
    {
        CompareInfoCompare test = new CompareInfoCompare();

        TestFramework.BeginTestCase("CompareInfo.Compare");

        if (test.RunTests())
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("PASS");
            return 100;
        }
        else
        {
            TestFramework.EndTestCase();
            TestFramework.LogInformation("FAIL");
            return 0;
        }

    }
        static int Main(string[] args)
        {
            bool success = true;

            // Load a fake mscoree.dll to avoid starting desktop
            LoadLibraryEx(Path.Combine(Environment.CurrentDirectory, "mscoree.dll"), IntPtr.Zero, 0);

            TestFramework.BeginScenario("Calling from managed to native IJW code");

            // Building with a reference to the IJW dll is difficult, so load via reflection instead
            TestFramework.BeginTestCase("Load IJW dll via reflection");
            Assembly ijwNativeDll = Assembly.Load("IjwNativeCallingManagedDll");

            TestFramework.EndTestCase();

            TestFramework.BeginTestCase("Call native method returning int");
            Type       testType     = ijwNativeDll.GetType("TestClass");
            object     testInstance = Activator.CreateInstance(testType);
            MethodInfo testMethod   = testType.GetMethod("ManagedEntryPoint");
            int        result       = (int)testMethod.Invoke(testInstance, null);

            if (result != 100)
            {
                TestFramework.LogError("IJW", "Incorrect result returned: " + result);
                success = false;
            }
            TestFramework.EndTestCase();

            TestFramework.BeginTestCase("Ensure .NET Framework was not loaded");
            IntPtr clrHandle = GetModuleHandle("mscoreei.dll");

            if (clrHandle != IntPtr.Zero)
            {
                TestFramework.LogError("IJW", ".NET Framework loaded by IJw module load");
                success = false;
            }
            TestFramework.EndTestCase();

            return(success ? 100 : 99);
        }