static void testLPStrBufferArrayOfStructs() { LPStrTestStruct[] lpss = null; lpss = new LPStrTestStruct[2]; lpss[0] = GetInvalidStruct(); lpss[1] = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_In_Array_Struct(lpss), "[Error] Location tlpsbaos1"); lpss = new LPStrTestStruct[2]; lpss[0] = GetValidStruct(); lpss[1] = GetValidStruct(); Assert.IsTrue(LPStrBuffer_In_Array_Struct(lpss), "[Error] Location tlpsbaos2"); lpss = new LPStrTestStruct[2]; lpss[0] = GetInvalidStruct(); lpss[1] = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_InByRef_Array_Struct(ref lpss), "[Error] Location tlpsbaos3"); lpss = new LPStrTestStruct[2]; lpss[0] = GetValidStruct(); lpss[1] = GetValidStruct(); Assert.IsTrue(LPStrBuffer_InByRef_Array_Struct(ref lpss), "[Error] Location tlpsbaos4"); lpss = new LPStrTestStruct[2]; lpss[0] = GetInvalidStruct(); lpss[1] = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_InOutByRef_Array_Struct(ref lpss), "[Error] Location tlpsbaos5"); lpss = new LPStrTestStruct[2]; lpss[0] = GetValidStruct(); lpss[1] = GetValidStruct(); LPStrTestStruct[] lpssClone = new LPStrTestStruct[2]; lpssClone[0].str = lpss[0].str; lpssClone[1].str = lpss[1].str; Assert.IsTrue(LPStrBuffer_InOutByRef_Array_Struct(ref lpss), "[Error] Location tlpsbaos6"); Assert.AreEqual(lpss[0].str, lpssClone[0].str, "[Error] Location tlpsbaos7"); }
static void testLPStrBufferStruct() { Assert.Throws <ArgumentException>(() => LPStrBuffer_In_Struct_String(GetInvalidStruct())); Assert.True(LPStrBuffer_In_Struct_String(GetValidStruct())); LPStrTestStruct cTemp = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_InByRef_Struct_String(ref cTemp)); cTemp = GetValidStruct(); Assert.True(LPStrBuffer_InByRef_Struct_String(ref cTemp)); cTemp = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_InOutByRef_Struct_String(ref cTemp)); cTemp = GetValidStruct(); LPStrTestStruct cTempClone = new LPStrTestStruct(); cTempClone.str = cTemp.str; Assert.True(LPStrBuffer_InOutByRef_Struct_String(ref cTemp)); Assert.Equal(cTempClone.str, cTemp.str); }
static void testLPStrBufferStruct() { Assert.Throws <ArgumentException>(() => LPStrBuffer_In_Struct_String(GetInvalidStruct()), "[Error] Location tlpsbst1"); Assert.IsTrue(LPStrBuffer_In_Struct_String(GetValidStruct()), "[Error] Location tlpsbst2"); LPStrTestStruct cTemp = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_InByRef_Struct_String(ref cTemp), "[Error] Location tlpsbst3"); cTemp = GetValidStruct(); Assert.IsTrue(LPStrBuffer_InByRef_Struct_String(ref cTemp), "[Error] Location tlpsbst4"); cTemp = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_InOutByRef_Struct_String(ref cTemp), "[Error] Location tlpsbst5"); cTemp = GetValidStruct(); LPStrTestStruct cTempClone = new LPStrTestStruct(); cTempClone.str = cTemp.str; Assert.IsTrue(LPStrBuffer_InOutByRef_Struct_String(ref cTemp), "[Error] Location tlpsbst6"); Assert.AreEqual(cTempClone.str, cTemp.str, "[Error] Location tlpsbst7"); }
static void testLPStrBufferArrayOfStructs() { LPStrTestStruct[] lpss = null; lpss = new LPStrTestStruct[2]; lpss[0] = GetInvalidStruct(); lpss[1] = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_In_Array_Struct(lpss)); lpss = new LPStrTestStruct[2]; lpss[0] = GetValidStruct(); lpss[1] = GetValidStruct(); Assert.True(LPStrBuffer_In_Array_Struct(lpss)); lpss = new LPStrTestStruct[2]; lpss[0] = GetInvalidStruct(); lpss[1] = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_InByRef_Array_Struct(ref lpss)); lpss = new LPStrTestStruct[2]; lpss[0] = GetValidStruct(); lpss[1] = GetValidStruct(); Assert.True(LPStrBuffer_InByRef_Array_Struct(ref lpss)); lpss = new LPStrTestStruct[2]; lpss[0] = GetInvalidStruct(); lpss[1] = GetInvalidStruct(); Assert.Throws <ArgumentException>(() => LPStrBuffer_InOutByRef_Array_Struct(ref lpss)); lpss = new LPStrTestStruct[2]; lpss[0] = GetValidStruct(); lpss[1] = GetValidStruct(); LPStrTestStruct[] lpssClone = new LPStrTestStruct[2]; lpssClone[0].str = lpss[0].str; lpssClone[1].str = lpss[1].str; Assert.True(LPStrBuffer_InOutByRef_Array_Struct(ref lpss)); Assert.Equal(lpss[0].str, lpssClone[0].str); }
public static extern bool LPStrBuffer_InOutByRef_Struct_String([In, Out][MarshalAs(UnmanagedType.Struct)] ref LPStrTestStruct strStruct);
public static extern bool LPStrBuffer_In_Struct_String([In][MarshalAs(UnmanagedType.Struct)] LPStrTestStruct strStruct);