Beispiel #1
0
        public void NamedPropertyExists_Null_test()
        {
            var            namedIdMap = IntegrationUtil.GetNameIdMap();
            INamedProperty property   = null;

            Assert.AreEqual(false, namedIdMap.NamedPropertyExists(property));
        }
Beispiel #2
0
        public void NamedPropertyExists_Valid_test()
        {
            var namedIdMap = IntegrationUtil.GetNameIdMap();

            INamedProperty property = namedIdMap.Lookup(0x8000);

            Assert.AreEqual(true, namedIdMap.NamedPropertyExists(property));
        }
Beispiel #3
0
        public void NamedPropertyExists_Invalid_test()
        {
            var namedIdMap = IntegrationUtil.GetNameIdMap();

            INamedProperty property = namedIdMap.Lookup(0x9999);

            namedIdMap.NamedPropertyExists(property);
        }
        public void NamedPropertyExists_Invalid_test()
        {
            var namedIdMap = IntegrationUtil.GetNameIdMap();

            INamedProperty property = namedIdMap.Lookup(NameIdMapMockConstants.NAMED_IDMAP_INVALID_PROP_ID);

            namedIdMap.NamedPropertyExists(property);
        }
Beispiel #5
0
        public PropId Lookup(INamedProperty namedProperty)
        {
            ushort guidIndex;

            try
            {
                guidIndex = GetGuidIndex(namedProperty.Guid);
            }
            catch (PstSdkException ex)
            {
                throw new PstSdkException("Unable to lookup Guid, was not found in guid stream", ex);
            }

            //If this is a MAPI Guid, handle accordingly
            if (guidIndex == 1)
            {
                if (namedProperty.IsString || namedProperty.ID >= 0x8000)
                {
                    throw new PstSdkException("Could not lookup named property.  Invalid NamedProperty");
                }

                return(guidIndex);
            }

            uint hashValue = ComputeHashValue(guidIndex, namedProperty);
            uint hashBase  = ComputeHashBase(namedProperty);

            if (!_propBag.PropertyExists(GetBucketProperty(hashValue)))
            {
                throw new PstSdkException("Could not find property in Hash Bucket");
            }

            using (var stream = _propBag.OpenPropertyStream(GetBucketProperty(hashValue)))
            {
                var bytes = new byte[NameId.NameIdSize];
                while (stream.Read(bytes, 0, NameId.NameIdSize) != 0)
                {
                    NameId nameId = bytes;
                    if ((nameId.Id == hashBase) &&
                        (nameId.IsString == namedProperty.IsString) &&
                        (nameId.GuidIndex == guidIndex))
                    {
                        if (nameId.IsString)
                        {
                            if (string.Compare(BuildNamedProperty((PropId)nameId.PropertyIndex).Name, namedProperty.Name) != 0)
                            {
                                continue;
                            }
                        }

                        return((PropId)(nameId.PropertyIndex + 0x8000));
                    }
                }
            }

            throw new PstSdkException("Could not find Property in NamedPropertyMap!");
        }
Beispiel #6
0
        private static uint ComputeHashBase(INamedProperty n)
        {
            if (n.IsString)
            {
                var bytes = Encoding.Unicode.GetBytes(n.Name);
                return(CRC.ComputeCRC(bytes, (uint)bytes.Length));
            }

            return(n.ID);
        }
Beispiel #7
0
        public void ComputeHashBaseTest()
        {
            INamedProperty n        = null; // TODO: Initialize to an appropriate value
            uint           expected = 0;    // TODO: Initialize to an appropriate value
            uint           actual;

            actual = NameIdMap_Accessor.ComputeHashBase(n);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #8
0
 public bool NamedPropertyExists(INamedProperty namedProperty)
 {
     try
     {
         Lookup(namedProperty);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #9
0
        public void NamedPropertyExistsTest()
        {
            IDBAccessor    database      = null;                    // TODO: Initialize to an appropriate value
            NameIdMap      target        = new NameIdMap(database); // TODO: Initialize to an appropriate value
            INamedProperty namedProperty = null;                    // TODO: Initialize to an appropriate value
            bool           expected      = false;                   // TODO: Initialize to an appropriate value
            bool           actual;

            actual = target.NamedPropertyExists(namedProperty);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #10
0
        public void LookupTest1()
        {
            IDBAccessor    database      = null;                    // TODO: Initialize to an appropriate value
            NameIdMap      target        = new NameIdMap(database); // TODO: Initialize to an appropriate value
            INamedProperty namedProperty = null;                    // TODO: Initialize to an appropriate value
            PropId         expected      = new PropId();            // TODO: Initialize to an appropriate value
            PropId         actual;

            actual = target.Lookup(namedProperty);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #11
0
        public bool TryResolveToNamedProperty(PropertyTag propertyTag, out NamedProperty namedProperty)
        {
            namedProperty = null;
            INamedProperty namedProperty2 = null;

            if (!propertyTag.IsNamedProperty || !this.pstMailbox.IPst.ReadNamedPropertyTable().TryGetValue((ushort)propertyTag.PropertyId, out namedProperty2))
            {
                return(false);
            }
            try
            {
                namedProperty = (namedProperty2.IsString ? new NamedProperty(namedProperty2.Guid, namedProperty2.Name) : new NamedProperty(namedProperty2.Guid, namedProperty2.Id));
            }
            catch (ArgumentException ex)
            {
                throw new ExArgumentException(ex.Message, ex);
            }
            return(true);
        }
Beispiel #12
0
 public PropId Lookup(INamedProperty namedProp)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
 public bool NamedPropertyExists(INamedProperty namedProp)
 {
     throw new NotImplementedException();
 }
Beispiel #14
0
 private static uint ComputeHashValue(ushort guidIndex, INamedProperty n)
 {
     return((uint)(n.IsString ? ((guidIndex << 1) | 1) : (guidIndex << 1)) ^ ComputeHashBase(n));
 }