/// <summary>
        /// This method is used to get object for different object types.
        /// </summary>
        /// <param name="objType">Specifies the object type.</param>
        /// <param name="objToOperate">Specifies which objects to operate.</param>
        public void GetObject(ServerObjectType objType, ObjectToOperate objToOperate)
        {
            this.cprptCurrentObj = objToOperate;

            if (objType == ServerObjectType.Logon)
            {
                this.cprptFirstHandle = this.cprptFirstObjectHandle = this.cprptCurrentHandle = this.cprptLogonHandle;
            }

            if (objType == ServerObjectType.Folder)
            {
                switch (objToOperate)
                {
                    case ObjectToOperate.FirstObject:
                        this.cprptFirstHandle = this.cprptFirstObjectHandle = this.cprptCurrentHandle = cprptFolderHandle[0];
                        break;
                    case ObjectToOperate.SecondObject:
                        this.cprptSecondHandle = this.cprptSecondObjectHandle = cprptFolderHandle[1];
                        break;
                    case ObjectToOperate.ThirdObject:
                        this.cprptCurrentHandle = cprptFolderHandle[2];
                        break;
                    case ObjectToOperate.FourthObject:
                        this.cprptCurrentHandle = cprptFolderHandle[3];
                        break;
                    case ObjectToOperate.FifthObject:
                        this.cprptCurrentHandle = cprptFolderHandle[1];
                        break;
                    default:
                        Site.Assert.Fail("Invalid ObjectToOperate enum value {0}.", objToOperate);
                        break;
                }
            }

            if (objType == ServerObjectType.Message)
            {
                switch (objToOperate)
                {
                    case ObjectToOperate.FirstObject:
                        this.cprptFirstHandle = this.cprptFirstObjectHandle = this.cprptCurrentHandle = cprptMessageHandle[0];
                        break;
                    case ObjectToOperate.SecondObject:
                        this.cprptSecondHandle = this.cprptSecondObjectHandle = cprptMessageHandle[1];
                        break;
                    case ObjectToOperate.ThirdObject:
                        this.cprptCurrentHandle = cprptMessageHandle[2];
                        break;
                    case ObjectToOperate.FourthObject:
                        this.cprptCurrentHandle = cprptMessageHandle[3];
                        break;
                    default:
                        Site.Assert.Fail("Invalid ObjectToOperate enum value {0}.", objToOperate);
                        break;
                }
            }

            if (objType == ServerObjectType.Attachment)
            {
                switch (objToOperate)
                {
                    case ObjectToOperate.FirstObject:
                        this.cprptFirstHandle = this.cprptFirstObjectHandle = this.cprptCurrentHandle = cprptAttachmentHandle[0];
                        break;
                    case ObjectToOperate.SecondObject:
                        this.cprptSecondHandle = this.cprptSecondObjectHandle = cprptAttachmentHandle[1];
                        break;
                    case ObjectToOperate.ThirdObject:
                        this.cprptCurrentHandle = cprptAttachmentHandle[2];
                        break;
                    case ObjectToOperate.FourthObject:
                        this.cprptCurrentHandle = cprptAttachmentHandle[3];
                        break;
                    default:
                        Site.Assert.Fail("Invalid ObjectToOperate enum value {0}.", objToOperate);
                        break;
                }
            }

            #region Set property

            TaggedPropertyValue[] taggedPropertyValueArray = new TaggedPropertyValue[1];
            RopSetPropertiesResponse ropSetPropertiesResponse;
            if (objType == ServerObjectType.Attachment)
            {
                // Add this property to attachment1.
                this.cprptCurrentType = ServerObjectType.Attachment;
                taggedPropertyValueArray[0] = this.GetTaggedPropertyTag(ObjectToOperate.FirstObject);
                taggedPropertyValueArray[0].Value = Common.AddInt16LengthBeforeBinaryArray(taggedPropertyValueArray[0].Value);
                ropSetPropertiesResponse = this.RopSetProperties(cprptAttachmentHandle[0], taggedPropertyValueArray, true);
                Site.Assert.AreEqual<uint>(0, ropSetPropertiesResponse.ReturnValue, "The properties should be set for the first object successfully.");
                RopSaveChangesAttachmentResponse ropSaveAttachmentResponse = this.RopSaveChangesAttachment(cprptAttachmentHandle[0], true);
                Site.Assert.AreEqual<uint>(0, ropSaveAttachmentResponse.ReturnValue, "The changes on Attachment should be saved successfully.");
                this.RopSaveChangesMessage(cprptMessageHandle[0], true);

                // Add this property to attachment2.
                taggedPropertyValueArray[0] = this.GetTaggedPropertyTag(ObjectToOperate.SecondObject);
                taggedPropertyValueArray[0].Value = Common.AddInt16LengthBeforeBinaryArray(taggedPropertyValueArray[0].Value);
                this.RopSetProperties(cprptAttachmentHandle[1], taggedPropertyValueArray, true);
                this.RopSaveChangesAttachment(cprptAttachmentHandle[1], true);
                this.RopSaveChangesMessage(cprptMessageHandle[0], true);
            }

            if (objType == ServerObjectType.Message)
            {
                // Add this property to message1.
                this.cprptCurrentType = ServerObjectType.Message;
                taggedPropertyValueArray[0] = this.GetTaggedPropertyTag(ObjectToOperate.FirstObject);
                taggedPropertyValueArray[0].Value = Common.AddInt16LengthBeforeBinaryArray(taggedPropertyValueArray[0].Value);
                this.RopSetProperties(cprptMessageHandle[0], taggedPropertyValueArray, true);
                this.RopSaveChangesMessage(cprptMessageHandle[0], true);

                // Add this property to message2.
                taggedPropertyValueArray[0] = this.GetTaggedPropertyTag(ObjectToOperate.SecondObject);
                taggedPropertyValueArray[0].Value = Common.AddInt16LengthBeforeBinaryArray(taggedPropertyValueArray[0].Value);
                this.RopSetProperties(cprptMessageHandle[1], taggedPropertyValueArray, true);
                this.RopSaveChangesMessage(cprptMessageHandle[1], true);
            }

            if (objType == ServerObjectType.Folder)
            {
                // Add this property to folder1.
                this.cprptCurrentType = ServerObjectType.Folder;
                taggedPropertyValueArray[0] = this.GetTaggedPropertyTag(ObjectToOperate.FirstObject);
                taggedPropertyValueArray[0].Value = Common.AddInt16LengthBeforeBinaryArray(taggedPropertyValueArray[0].Value);
                this.RopSetProperties(cprptFolderHandle[0], taggedPropertyValueArray, true);

                // Add this property to folder2.
                taggedPropertyValueArray[0] = this.GetTaggedPropertyTag(ObjectToOperate.SecondObject);
                taggedPropertyValueArray[0].Value = Common.AddInt16LengthBeforeBinaryArray(taggedPropertyValueArray[0].Value);
                this.RopSetProperties(cprptFolderHandle[1], taggedPropertyValueArray, true);

                // Set PTagRulesData property for folder1 and folder2
                taggedPropertyValueArray[0] = this.GetTaggedPropertyTag(ObjectToOperate.ThirdObject);
                taggedPropertyValueArray[0].Value = Common.AddInt16LengthBeforeBinaryArray(taggedPropertyValueArray[0].Value);
                this.RopSetProperties(cprptFolderHandle[0], taggedPropertyValueArray, true);
                this.RopSetProperties(cprptFolderHandle[1], taggedPropertyValueArray, true);
            }

            if (objType == ServerObjectType.Logon)
            {
                // Add this property to logon.
                this.cprptCurrentType = ServerObjectType.Logon;
                taggedPropertyValueArray[0] = this.GetTaggedPropertyTag(ObjectToOperate.FirstObject);
                this.RopSetProperties(this.cprptLogonHandle, taggedPropertyValueArray, true);
            }

            // Set current type.
            this.cprptCurrentType = objType;

            #endregion
        }
        /// <summary>
        /// This method is used to release all resources associated with a Server object. 
        /// The client uses RopRelease ([MS-OXCROPS] section 2.2.14.3) after it is done with the Stream object.
        /// </summary>
        /// <param name="obj">Specifies which object will be operated.</param>
        public void RopReleaseMethodNoVerify(ObjectToOperate obj)
        {
            // The handle to release.
            uint handle = 0;
            if (obj == ObjectToOperate.FirstObject)
            {
                handle = this.cprptFirstHandle;
            }
            else
            {
                handle = this.cprptSecondHandle;
            }

            this.RopRelease(handle);
        }
        /// <summary>
        /// Get TaggedProperty from ptfconfig file.
        /// </summary>
        /// <param name="obj">The order of object to get.</param>
        /// <returns>Return TaggedProperty.</returns>
        private TaggedPropertyValue GetTaggedPropertyTag(ObjectToOperate obj)
        {
            TaggedPropertyValue propertyTag = new TaggedPropertyValue();
            switch (this.cprptCurrentType)
            {
                case ServerObjectType.Logon:
                    if (obj == ObjectToOperate.FirstObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("LogonPropertyID0", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("LogonPropertyType0", this.Site));
                        propertyTag.Value = BitConverter.GetBytes(Convert.ToBoolean(Common.GetConfigurationPropertyValue("LogonPropertyValue0", this.Site)));
                    }
                    else if (obj == ObjectToOperate.SecondObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("LogonPropertyID1", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("LogonPropertyType1", this.Site));
                        propertyTag.Value = Encoding.ASCII.GetBytes(Common.GetConfigurationPropertyValue("LogonPropertyValue1", this.Site) + "\0");
                    }

                    break;

                case ServerObjectType.Attachment:
                    if (obj == ObjectToOperate.FirstObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("AttachmentPropertyID0", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("AttachmentPropertyType0", this.Site));
                        propertyTag.Value = Encoding.ASCII.GetBytes(Common.GetConfigurationPropertyValue("AttachmentPropertyValue0", this.Site) + "\0");
                    }
                    else if (obj == ObjectToOperate.SecondObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("AttachmentPropertyID1", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("AttachmentPropertyType1", this.Site));
                        propertyTag.Value = Encoding.ASCII.GetBytes(Common.GetConfigurationPropertyValue("AttachmentPropertyValue1", this.Site) + "\0");
                    }

                    break;

                case ServerObjectType.Folder:
                    if (obj == ObjectToOperate.FirstObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("FolderPropertyID0", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("FolderPropertyType0", this.Site));
                        propertyTag.Value = Encoding.ASCII.GetBytes(Common.GetConfigurationPropertyValue("FolderPropertyValue0", this.Site) + "\0");
                    }
                    else if (obj == ObjectToOperate.SecondObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("FolderPropertyID1", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("FolderPropertyType1", this.Site));
                        propertyTag.Value = Encoding.ASCII.GetBytes(Common.GetConfigurationPropertyValue("FolderPropertyValue1", this.Site) + "\0");
                    }
                    else if (obj == ObjectToOperate.ThirdObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("FolderPropertyID2", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("FolderPropertyType2", this.Site));
                        propertyTag.Value = Encoding.ASCII.GetBytes(Common.GetConfigurationPropertyValue("FolderPropertyValue2", this.Site) + "\0");
                    }

                    break;

                case ServerObjectType.Message:
                    if (obj == ObjectToOperate.FirstObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("MessagePropertyID0", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("MessagePropertyType0", this.Site));
                        propertyTag.Value = Encoding.ASCII.GetBytes(Common.GetConfigurationPropertyValue("MessagePropertyValue0", this.Site) + "\0");
                    }
                    else if (obj == ObjectToOperate.SecondObject)
                    {
                        propertyTag.PropertyTag.PropertyId = Convert.ToUInt16(Common.GetConfigurationPropertyValue("MessagePropertyID1", this.Site));
                        propertyTag.PropertyTag.PropertyType = Convert.ToUInt16(Common.GetConfigurationPropertyValue("MessagePropertyType1", this.Site));
                        propertyTag.Value = Encoding.ASCII.GetBytes(Common.GetConfigurationPropertyValue("MessagePropertyValue1", this.Site) + "\0");
                    }

                    break;

                default:
                    Site.Assert.Fail("Invalid ServerObjectType enum value {0}.", this.cprptCurrentType);
                    break;
            }

            return propertyTag;
        }
        /// <summary>
        /// This method is used to open a different type of properties as a Stream object, enabling the client to perform various streaming operations on the property. 
        /// </summary>
        /// <param name="obj">Specifies which object will be operated.</param>
        /// <param name="propertyType">Specifies which type of property will be operated.</param>
        /// <param name="error">Returned error code.</param>
        public void RopOpenStreamWithDifferentPropertyType(ObjectToOperate obj, PropertyTypeName propertyType, out CPRPTErrorCode error)
        {
            #region Initialize properties and parameter
            error = CPRPTErrorCode.None;
            TaggedPropertyValue propertyTag = this.GetTaggedPropertyTag(obj);

            uint handle = 0;
            switch (this.cprptCurrentType)
            {
                case ServerObjectType.Folder:
                    int index = obj == ObjectToOperate.FifthObject ? (int)ObjectToOperate.FirstObject : (int)obj;
                    handle = cprptFolderHandle[index];
                    break;
                case ServerObjectType.Message:
                    handle = cprptMessageHandle[(int)obj];
                    break;
                case ServerObjectType.Attachment:
                    handle = cprptAttachmentHandle[(int)obj];
                    break;
                default:
                    break;
            }

            byte openModeFlags = ConstValues.OpenModeFlagsCreate;
            propertyTag.PropertyTag.PropertyType = (ushort)propertyType;

            if (this.cprptCurrentType != ServerObjectType.Folder)
            {
                propertyTag.PropertyTag.PropertyId++;
            }
            else
            {
                if (obj == ObjectToOperate.FifthObject)
                {
                    switch (propertyType)
                    {
                        case PropertyTypeName.PtypBinary:
                            propertyTag.PropertyTag.PropertyId = 0x0e09;
                            propertyTag.PropertyTag.PropertyType = 0x0102;
                            break;
                        case PropertyTypeName.PtypString:
                            propertyTag.PropertyTag.PropertyId = 0x3001;
                            propertyTag.PropertyTag.PropertyType = 0x001f;
                            break;
                        default:
                            break;
                    }

                    openModeFlags = ConstValues.OpenModeFlagsReadOnly;
                }
                else
                {
                    // Set PTagRulesData property for Folder object
                    propertyTag.PropertyTag.PropertyId = ushort.Parse(Common.GetConfigurationPropertyValue("FolderPropertyID2", this.Site));
                }
            }

            error = CPRPTErrorCode.Other;

            #endregion
            RopOpenStreamResponse openStreamResponse;
            uint openHandle = this.RopOpenStream(handle, out openStreamResponse, propertyTag.PropertyTag, openModeFlags, false);

            error = (CPRPTErrorCode)openStreamResponse.ReturnValue;

            #region Write stream to verify having write permission
            if (this.cprptCurrentType == ServerObjectType.Message)
            {
                RopWriteStreamResponse writeStreamResponse = this.RopWriteStream(openHandle, WriteData, false);
                this.RopCommitStream(openHandle, false);

                this.VerifyRopWriteStreamWithCreatePermission(writeStreamResponse);
            }
            #endregion
        }
        /// <summary>
        /// This method is used to release all resources associated with a Server object. 
        /// The client uses RopRelease ([MS-OXCROPS] section 2.2.14.3) after it is done with the Stream object.
        /// </summary>
        /// <param name="obj">Specifies which object will be operated.</param>
        /// <param name="isPropertyValueChanged">For Folder Object, this ROP should not change the value 
        /// in stream after RopWriteStream.For non-Folder Object, this ROP should change the value.</param>
        public void RopReleaseMethod(ObjectToOperate obj, out bool isPropertyValueChanged)
        {
            this.RopReleaseMethodNoVerify(obj);

            string objKey = string.Empty;

            // Save attachment and message to enforce changes.
            switch (this.cprptCurrentType)
            {
                case ServerObjectType.Message:
                    if (obj == ObjectToOperate.FirstObject)
                    {
                        objKey = "Message1";
                        this.RopSaveChangesMessage(cprptMessageHandle[0], true);
                    }
                    else
                    {
                        objKey = "Message2";
                        this.RopSaveChangesMessage(cprptMessageHandle[1], true);
                    }

                    break;
                case ServerObjectType.Attachment:
                    if (obj == ObjectToOperate.FirstObject)
                    {
                        objKey = "Attachment1";
                        this.RopSaveChangesAttachment(cprptAttachmentHandle[0], true);
                        this.RopSaveChangesMessage(cprptMessageHandle[0], true);
                    }
                    else
                    {
                        objKey = "Attachment2";
                        this.RopSaveChangesAttachment(cprptAttachmentHandle[1], true);
                        this.RopSaveChangesMessage(cprptMessageHandle[1], true);
                    }

                    break;
                case ServerObjectType.Folder:
                    if (obj == ObjectToOperate.FirstObject)
                    {
                        objKey = "Folder1";
                    }
                    else
                    {
                        objKey = "Folder2";
                    }

                    break;
                default:
                    break;
            }

            // Check whether it is changed in DB.
            bool isPropertyFound;
            byte[] propertyValueAfterWriteStream = this.Session2ReadStream(objKey, this.tagPropertyValuesToVerification[objKey].PropertyTag, out isPropertyFound);
            isPropertyValueChanged = !Common.CompareByteArray(propertyValueAfterWriteStream, this.tagPropertyValuesToVerification[objKey].Value);
        }
示例#6
0
        public static void RopOpenStreamWithDifferentPropertyType(
            ObjectToOperate objectToOperate,
            PropertyTypeName propertyType,
            out CPRPTErrorCode error)
        {
            Condition.IsTrue(isInitialized);
            Condition.IsTrue(globalObj != ServerObjectType.Logon);
            Condition.IfThen(globalObj == ServerObjectType.Message || globalObj == ServerObjectType.Attachment, propertyType == PropertyTypeName.PtypBinary || propertyType == PropertyTypeName.PtypString || propertyType == PropertyTypeName.PtypObject);

            if (objectToOperate == ObjectToOperate.FirstObject)
            {
                Condition.IfThen(globalObj == ServerObjectType.Folder, propertyType == PropertyTypeName.PtypBinary);
            }
            else if (objectToOperate == ObjectToOperate.FifthObject)
            {
                Condition.IfThen(globalObj == ServerObjectType.Folder, propertyType == PropertyTypeName.PtypBinary || propertyType == PropertyTypeName.PtypString);
            }

            // openFlag and error is designed for negative test case.
            error = CPRPTErrorCode.None;            
            if (globalObj == ServerObjectType.Attachment && propertyType == PropertyTypeName.PtypBinary)
            {
                ModelHelper.CaptureRequirement(
                    25502,
                    @"[In RopOpenStream ROP] Single-valued PtypBinary type properties ([MS-OXCDATA] section 2.11.1) is supported for Attachment objects.");
            }

            if (globalObj == ServerObjectType.Attachment && propertyType == PropertyTypeName.PtypObject)
            {
                ModelHelper.CaptureRequirement(
                    25503,
                    @"[In RopOpenStream ROP] Single-valued PtypObject type properties ([MS-OXCDATA] section 2.11.1) is supported for Attachment objects.");
            }

            if (globalObj == ServerObjectType.Message && propertyType == PropertyTypeName.PtypBinary)
            {
                ModelHelper.CaptureRequirement(
                   25506,
                   @"[In RopOpenStream ROP] Single-valued PtypBinary type properties ([MS-OXCDATA] section 2.11.1) is supported for Message objects.");
            }

            if (globalObj == ServerObjectType.Message && propertyType == PropertyTypeName.PtypObject)
            {
                ModelHelper.CaptureRequirement(
                   25507,
                   @"[In RopOpenStream ROP] Single-valued PtypObject type properties ([MS-OXCDATA] section 2.11.1) is supported for Message objects.");
            }

            if (globalObj == ServerObjectType.Message && propertyType == PropertyTypeName.PtypString)
            {
                ModelHelper.CaptureRequirement(
                   25509,
                   @"[In RopOpenStream ROP] Single-valued PtypString type properties ([MS-OXCDATA] section 2.11.1) is supported for Message objects.");
            }

            if (globalObj == ServerObjectType.Attachment && propertyType == PropertyTypeName.PtypString)
            {
                if (requirementContainer[25505])
                {
                    ModelHelper.CaptureRequirement(
                        25505,
                        @"[In RopOpenStream ROP] Single-valued PtypString type properties ([MS-OXCDATA] section 2.11.1) is supported for Attachment objects.");
                }
                else
                {
                    error = CPRPTErrorCode.NotSupported;
                }            
            }
        }
        /// <summary>
        /// This method is used to open a property as a Stream object, enabling the client to perform various streaming operations on the property. 
        /// </summary>
        /// <param name="obj">Specifies which object will be operated.</param>
        /// <param name="openFlag">Specifies OpenModeFlags for [RopOpenStream].</param>
        /// <param name="isPropertyTagExist">Indicates whether request property exist.</param>
        /// <param name="isStreamSizeEqualToStream">Indicates whether StreamSize in response is 
        /// the same with the current number of BYTES in the stream.</param>
        /// <param name="error">If the property tag does not exist for the object and "Create" 
        /// is not specified in OpenModeFlags, NotFound error should be returned.</param>
        public void RopOpenStreamMethod(ObjectToOperate obj, OpenModeFlags openFlag, bool isPropertyTagExist, out bool isStreamSizeEqualToStream, out CPRPTErrorCode error)
        {
            #region Initialize properties and parameter
            error = CPRPTErrorCode.None;
            isStreamSizeEqualToStream = false;
            TaggedPropertyValue propertyTag = this.GetTaggedPropertyTag(obj);

            uint handle = 0;
            switch (this.cprptCurrentType)
            {
                case ServerObjectType.Folder:
                    handle = cprptFolderHandle[(int)obj];

                    // For folder object, open PTagRulesData property
                    propertyTag = this.GetTaggedPropertyTag(ObjectToOperate.ThirdObject);
                    break;
                case ServerObjectType.Message:
                    handle = cprptMessageHandle[(int)obj];
                    break;
                case ServerObjectType.Attachment:
                    handle = cprptAttachmentHandle[(int)obj];
                    break;
                default:
                    Site.Assert.Fail("Invalid server object type {0} for RopOpenStream method.", this.cprptCurrentType);
                    break;
            }

            byte openModeFlags = ConstValues.OpenModeFlagsReadOnly;
            switch (openFlag)
            {
                case OpenModeFlags.ReadOnly:
                    openModeFlags = ConstValues.OpenModeFlagsReadOnly;
                    break;
                case OpenModeFlags.ReadWrite:
                    openModeFlags = ConstValues.OpenModeFlagsReadWrite;
                    break;
                case OpenModeFlags.Create:
                    openModeFlags = ConstValues.OpenModeFlagsCreate;
                    break;
                case OpenModeFlags.BestAccess:
                    openModeFlags = ConstValues.OpenModeFlagsBestAccess;
                    break;
                default:
                    this.Site.Assert.Fail("Invalid OpenModeFlags enum value {0}.", openFlag);
                    break;
            }

            if (isPropertyTagExist)
            {
                #region Get original stream value of current property tag
                string objKey;
                switch (this.cprptCurrentType)
                {
                    case ServerObjectType.Folder:
                        if (obj == ObjectToOperate.FirstObject)
                        {
                            objKey = "Folder1";
                        }
                        else
                        {
                            objKey = "Folder2";
                        }

                        break;
                    case ServerObjectType.Message:
                        if (obj == ObjectToOperate.FirstObject)
                        {
                            objKey = "Message1";
                        }
                        else
                        {
                            objKey = "Message2";
                        }

                        break;
                    case ServerObjectType.Attachment:
                        if (obj == ObjectToOperate.FirstObject)
                        {
                            objKey = "Attachment1";
                        }
                        else
                        {
                            objKey = "Attachment2";
                        }

                        break;
                    default:
                        objKey = string.Empty;
                        break;
                }

                bool isPropertyFound;
                byte[] originalStreamValue = this.Session2ReadStream(objKey, propertyTag.PropertyTag, out isPropertyFound);

                // Store the value for further verification
                TaggedPropertyValue tagPropertyValue = new TaggedPropertyValue
                {
                    PropertyTag = propertyTag.PropertyTag,
                    Value = originalStreamValue
                };

                if (this.tagPropertyValuesToVerification.ContainsKey(objKey))
                {
                    this.tagPropertyValuesToVerification[objKey] = tagPropertyValue;
                }
                else
                {
                    this.tagPropertyValuesToVerification.Add(objKey, tagPropertyValue);
                }
                #endregion
            }
            else
            {
                propertyTag.PropertyTag.PropertyId = NewCreatePropertyID;
                propertyTag.PropertyTag.PropertyType = (ushort)PropertyTypeName.PtypBinary;
            }

            error = CPRPTErrorCode.None;
            isStreamSizeEqualToStream = false;
            #endregion

            RopOpenStreamResponse openStreamResponse;
            uint openHandle = this.RopOpenStream(handle, out openStreamResponse, propertyTag.PropertyTag, openModeFlags, false);

            this.VerifyRopOpenStream(openStreamResponse, this.cprptCurrentType, isPropertyTagExist, openFlag);

            #region Verify error, isStreamSizeEqualToStream and set handle
            if (openFlag != OpenModeFlags.Create && isPropertyTagExist == false && openStreamResponse.ReturnValue == (uint)CPRPTErrorCode.NotFound)
            {
                error = CPRPTErrorCode.NotFound;
            }
            else if (openStreamResponse.ReturnValue == (uint)CPRPTErrorCode.None)
            {
                error = CPRPTErrorCode.None;
                uint streamSize = openStreamResponse.StreamSize;
                switch (obj)
                {
                    case ObjectToOperate.FirstObject:
                        this.cprptCurrentHandle = this.cprptFirstHandle = openHandle;
                        break;
                    case ObjectToOperate.SecondObject:
                        this.cprptSecondHandle = openHandle;
                        break;
                    default:
                        break;
                }

                RopSeekStreamResponse res = this.RopSeekStream(openHandle, (byte)Origin.End, ConstValues.RopSeekStreamOffsetZero, false);
                if (res.ReturnValue == (uint)CPRPTErrorCode.None)
                {
                    if (streamSize == res.NewPosition)
                    {
                        isStreamSizeEqualToStream = true;
                    }
                }
            }
            #endregion
        }
示例#8
0
        public static void RopOpenStreamMethod(
            ObjectToOperate objectToOperate,
            OpenModeFlags openFlag,
            bool isPropertyTagExist,
            out bool isStreamSizeEqualToStream,
            out CPRPTErrorCode error)
        {
            Condition.IsTrue(isInitialized);
            Condition.IsTrue(globalObj != ServerObjectType.Logon);

            // openFlag and error is designed for negative test case.
            error = CPRPTErrorCode.None;
            isStreamSizeEqualToStream = false;
            isStreamWriteSuccess = false;
            isStreamOpenedSuccess = true;

            streamOpenFlag = openFlag;
            ModelHelper.CaptureRequirement(
                885,
                @"[In Processing RopOpenStream] The server MUST open the stream in the mode indicated by the OpenModeFlags field as specified by the table in section 2.2.14.1.");

            if (isPropertyTagExist)
            {
                isStreamSizeEqualToStream = true;
            }
            else if (openFlag == OpenModeFlags.ReadOnly && isPropertyTagExist == false)
            {
                error = CPRPTErrorCode.NotFound;
                isStreamOpenedSuccess = false;
            }
        }
示例#9
0
        public static void GetObject2(ServerObjectType objType, ObjectToOperate objToOperate)
        {
            Condition.IsTrue(objType == globalObj && isFirstObjectGot);
            Condition.IsTrue(objToOperate == ObjectToOperate.SecondObject);

            isSecondObjectGot = true;
        }
示例#10
0
        public static void GetObject1(ServerObjectType objType, ObjectToOperate objToOperate)
        {
            Condition.IsTrue(objToOperate == ObjectToOperate.FirstObject || objToOperate == ObjectToOperate.FifthObject);

            isFirstObjectGot = true;
            globalObj = objType;
        }
示例#11
0
 public static void RopReleaseMethodNoVerify(ObjectToOperate obj)
 {
     Condition.IsTrue(isInitialized && isStreamOpenedSuccess);
 }
示例#12
0
        public static void RopReleaseMethod(ObjectToOperate obj, out bool isPropertyValueChanged)
        {
            Condition.IsTrue(isInitialized && isStreamOpenedSuccess);
            isPropertyValueChanged = false;

            if (isStreamWriteSuccess)
            {
                isPropertyValueChanged = true;
                if (globalObj == ServerObjectType.Attachment)
                {
                    ModelHelper.CaptureRequirement(
                        56404,
                        @"[In Processing RopWriteStream] For an Attachment object, the new value is persisted to the database when a successful RopSaveChangesAttachment ROP ([MS-OXCROPS] section 2.2.6.15) followed by a successful RopSaveChangesMessage ROP is issued.");
                }

                if (globalObj == ServerObjectType.Message)
                {
                    ModelHelper.CaptureRequirement(
                          56403,
                          @"[In Processing RopWriteStream] For a Message object, the new value is persisted to the database when a successful RopSaveChangesMessage ROP ([MS-OXCROPS] section 2.2.6.3) is issued.");
                }
            }

            // Check if the previous RopWriteStream is success
            if (isStreamWriteSuccess)
            {
                isPropertyValueChanged = true;
            }
        }