Esempio n. 1
0
        public MFTestResults VerifyFlush()
        {
            MFTestResults result = MFTestResults.Pass;

            try
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    byte[] data = MFUtilities.GetRandomBytes(5000);
                    ms.Write(data, 0, data.Length);
                    ms.Flush();
                    if (ms.Length != 5000)
                    {
                        result = MFTestResults.Fail;
                        Log.Exception("Expected 5000 bytes, but got " + ms.Length);
                    }
                }
            }
            catch (Exception ex)
            {
                result = MFTestResults.Fail;
                Log.Exception("Unexpected exception", ex);
            }
            return(result);
        }
Esempio n. 2
0
        public MFTestResults UInt_Ushort_Constructor_Test7()
        {
            /// <summary>
            /// 1. Creates a Guid(uint, ushort, byte, byte ...)
            /// 2. Verifies exception is not thrown
            /// </summary>
            ///

            MFTestResults testResult = MFTestResults.Pass;
            Random        random     = new Random();
            int           randoInt   = random.Next(Int32.MaxValue);
            uint          _uInt      = (uint)(randoInt * 2);
            ushort        _uShort1   = (ushort)random.Next(65536);
            ushort        _uShort2   = (ushort)random.Next(65536);

            Byte[] _bArr = MFUtilities.GetRandomBytes(8);

            try
            {
                Guid _guid = new Guid(_uInt, _uShort1, _uShort1, _bArr[0], _bArr[1], _bArr[2], _bArr[3], _bArr[4], _bArr[5], _bArr[6], _bArr[7]);
            }
            catch (Exception ex)
            {
                Log.Comment("Caught : " + ex.Message + "when creating Guid(" + _uInt +
                            ", " + _uShort1 + ", " + _uShort1 + ", " + _bArr[0] +
                            ", " + _bArr[1] + ", " + _bArr[2] + ", " + _bArr[3] + ", " +
                            _bArr[4] + ", " + _bArr[5] + ", " + _bArr[6] + ", " + _bArr[7] + ")");
                testResult = MFTestResults.Fail;
            }

            return(testResult);
        }
Esempio n. 3
0
        public MFTestResults ByteArrayConstructor_Test2()
        {
            /// <summary>
            /// 1. Creates a Guid with byte Array of size 16 and random byte values
            /// 2. Verifies exception is not thrown
            /// </summary>
            ///

            MFTestResults testResult = MFTestResults.Pass;

            Byte[] guid16 = MFUtilities.GetRandomBytes(16);
            try
            {
                Guid myGuid1 = new Guid(guid16);
            }
            catch (Exception ex)
            {
                Log.Comment("Caught : " + ex.Message);
                testResult = MFTestResults.Fail;
            }

            return(testResult);
        }
Esempio n. 4
0
        public MFTestResults ArgumentException_Test3()
        {
            /// <summary>
            /// 1. Creates a Guid with byte Array of random size b/n 0 to 100 but not 16
            /// 2. Verifies ArgumentException is thrown
            /// </summary>
            ///

            MFTestResults testResult = MFTestResults.Fail;
            int           size       = 16;

            //size could be set to any Random number b/n 0 and 2147483647
            //System.OutOfMemoryException will be thrown
            Random random = new Random();

            while (size == 16)
            {
                size = random.Next(100);
            }
            Byte[] guidNot16 = MFUtilities.GetRandomBytes(size);
            try
            {
                Guid myGuid1 = new Guid(guidNot16);
            }
            catch (ArgumentException ex)
            {
                Log.Comment("Caught : " + ex.Message + " when trying to create Guid with " + size + " bytes long");
                testResult = MFTestResults.Pass;
            }
            catch (Exception e)
            {
                Log.Comment("Expecting ArgumentException got " + e.Message);
            }

            return(testResult);
        }
Esempio n. 5
0
 private byte[] GetByteArray(int length)
 {
     return(MFUtilities.GetRandomBytes(length));
 }