public void MSOXNSPI_S03_TC04_ResolveNamesWStringConversion() { this.CheckProductSupported(); this.CheckMAPIHTTPTransportSupported(); #region Call NspiBind to initiate a session between the client and the server. uint flags = 0; STAT stat = new STAT(); stat.InitiateStat(); FlatUID_r guid = new FlatUID_r { Ab = new byte[16] }; FlatUID_r?serverGuid = guid; this.Result = this.ProtocolAdatper.NspiBind(flags, stat, ref serverGuid); Site.Assert.AreEqual(ErrorCodeValue.Success, this.Result, "NspiBind should return Success!"); #endregion #region Call NspiResolveNamesW to require the string properties to be different with their native type. uint reservedOfResolveNamesW = 0; WStringsArray_r wstrArray; wstrArray.CValues = 1; wstrArray.LppszW = new string[wstrArray.CValues]; wstrArray.LppszW[0] = Common.GetConfigurationPropertyValue("User2Name", this.Site); PropertyTagArray_r propTags = new PropertyTagArray_r { CValues = 2, AulPropTag = new uint[] { AdapterHelper.ConvertStringToString8((uint)AulProp.PidTagAddressBookDisplayNamePrintable), AdapterHelper.ConvertString8ToString((uint)AulProp.PidTagDisplayName) } }; PropertyTagArray_r?mids; PropertyRowSet_r? rowOfResolveNamesW; this.Result = this.ProtocolAdatper.NspiResolveNamesW(reservedOfResolveNamesW, stat, propTags, wstrArray, out mids, out rowOfResolveNamesW); Site.Assert.AreEqual(ErrorCodeValue.Success, this.Result, "NspiResolveNamesW should return Success!"); Site.Assert.IsNotNull(rowOfResolveNamesW, "PropertyRowSet_r value should not null. The row number is {0}.", rowOfResolveNamesW == null ? 0 : rowOfResolveNamesW.Value.CRows); Site.Assert.AreNotEqual <int>(0, rowOfResolveNamesW.Value.ARow.Length, "At least one address book object should be matched."); PropertyRow_r rowValue = rowOfResolveNamesW.Value.ARow[0]; string resolvedDisplayNamePrintable = System.Text.UnicodeEncoding.UTF8.GetString(rowValue.LpProps[0].Value.LpszA); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXNSPI_R1979: The value of PidTagAddressBookDisplayNamePrintable is {0}.", resolvedDisplayNamePrintable); // Verify MS-OXNSPI requirement: MS-OXNSPI_R1979 // The field LpszA indicates an 8-bit character string value. Site.CaptureRequirementIfIsTrue( resolvedDisplayNamePrintable.StartsWith(wstrArray.LppszW[0], StringComparison.Ordinal), 1979, "[In Conversion Rules for String Values Specified by the Server to the Client] In NspiResolveNamesW method, String values can be returned in 8-bit character representation in the output parameter ppRows."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXNSPI_R1978"); string reslovedName = System.Text.UnicodeEncoding.Unicode.GetString(rowValue.LpProps[1].Value.LpszW); // Verify MS-OXNSPI requirement: MS-OXNSPI_R1978 // The field LpszW indicates a single Unicode string value. Site.CaptureRequirementIfAreEqual <string>( wstrArray.LppszW[0].ToLower(System.Globalization.CultureInfo.CurrentCulture), reslovedName.ToLower(System.Globalization.CultureInfo.CurrentCulture), 1978, "[In Conversion Rules for String Values Specified by the Server to the Client] In NspiResolveNamesW method, String values can be returned in Unicode representation in the output parameter ppRows."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXNSPI_R1939"); // Verify MS-OXNSPI requirement: MS-OXNSPI_R1939 // The native type of PidTagAddressBookDisplayNamePrintable is PtypString and the client has requested this property with PtypString8. Site.CaptureRequirementIfAreEqual <uint>( AdapterHelper.ConvertStringToString8((uint)AulProp.PidTagAddressBookDisplayNamePrintable), rowValue.LpProps[0].PropTag, 1939, "[In Conversion Rules for String Values Specified by the Server to the Client] [For method NspiResolveNamesW] If the native type of a property is PtypString and the client has requested that property with the type PtypString8, the server MUST convert the Unicode representation to an 8-bit character representation in the code page specified by the CodePage field of the pStat parameter prior to returning the value."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXNSPI_R1955"); // Verify MS-OXNSPI requirement: MS-OXNSPI_R1955 // The native type of PidTagDisplayName is PtypString8 and the client has requested this property with PtypString. Site.CaptureRequirementIfAreEqual <uint>( AdapterHelper.ConvertString8ToString((uint)AulProp.PidTagDisplayName), rowValue.LpProps[1].PropTag, 1955, "[In Conversion Rules for String Values Specified by the Server to the Client] [For method NspiResolveNamesW] If the native type of a property is PtypString8 and the client has requested that property with the type PtypString, the server MUST convert the 8-bit character representation to a Unicode representation prior to returning the value."); #endregion #region Call NspiResolveNamesW to require the string properties to be the same as their native types. wstrArray.CValues = 1; wstrArray.LppszW = new string[wstrArray.CValues]; wstrArray.LppszW[0] = Common.GetConfigurationPropertyValue("User2Name", this.Site); propTags = new PropertyTagArray_r { CValues = 2, AulPropTag = new uint[] { (uint)AulProp.PidTagAddressBookDisplayNamePrintable, (uint)AulProp.PidTagDisplayName } }; this.Result = this.ProtocolAdatper.NspiResolveNamesW(reservedOfResolveNamesW, stat, propTags, wstrArray, out mids, out rowOfResolveNamesW); Site.Assert.AreEqual(ErrorCodeValue.Success, this.Result, "NspiResolveNamesW should return Success!"); Site.Assert.IsNotNull(rowOfResolveNamesW, "PropertyRowSet_r value should not null. The row number is {0}.", rowOfResolveNamesW == null ? 0 : rowOfResolveNamesW.Value.CRows); Site.Assert.AreNotEqual <int>(0, rowOfResolveNamesW.Value.ARow.Length, "At least one address book object should be matched."); rowValue = rowOfResolveNamesW.Value.ARow[0]; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXNSPI_R1946"); // Verify MS-OXNSPI requirement: MS-OXNSPI_R1947 // The native type of PidTagAddressBookDisplayNamePrintable is PtypString and the client has requested this property with PtypString. Site.CaptureRequirementIfAreEqual <uint>( (uint)AulProp.PidTagAddressBookDisplayNamePrintable, rowValue.LpProps[0].PropTag, 1947, "[In Conversion Rules for String Values Specified by the Server to the Client] [For method NspiResolveNamesW] If the native type of a property is PtypString and the client has requested that property with the type PtypString, the server MUST return the Unicode representation unmodified."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXNSPI_R1963"); // Verify MS-OXNSPI requirement: MS-OXNSPI_R1963 // The native type of PidTagDisplayName is PtypString8 and the client has requested this property with PtypString8. Site.CaptureRequirementIfAreEqual <uint>( (uint)AulProp.PidTagDisplayName, rowValue.LpProps[1].PropTag, 1963, "[In Conversion Rules for String Values Specified by the Server to the Client] [For method NspiResolveNamesW] If the native type of a property is PtypString8 and the client has requested that property with the type PtypString8, the server MUST return the 8-bit character representation unmodified."); #endregion #region Call NspiUnbind method to destroy the context handle. uint returnValue = this.ProtocolAdatper.NspiUnbind(0); Site.Assert.AreEqual <uint>(1, returnValue, "NspiUnbind method should return 1 (Success)."); #endregion }