#81 TWIdentity flag properties not set correctly

This commit is contained in:
Eugene 2017-04-24 10:06:23 -04:00
parent a11add856d
commit 89a87dea36
2 changed files with 25 additions and 3 deletions

View File

@ -49,5 +49,27 @@ namespace NTwain.Tests.Data
string badString = new String('a', overLength);
target.ProductName = badString;
}
[TestMethod]
public void Setting_and_Unsetting_the_Shared_Flag_Properties_Works()
{
TWIdentity id = new TWIdentity();
// these 2 flag properties are store in same int value so needs to test together
id.DataFunctionalities = DataFunctionalities.App2;
id.DataGroup = DataGroups.Audio;
Assert.AreEqual(DataFunctionalities.App2, id.DataFunctionalities);
Assert.AreEqual(DataGroups.Audio, id.DataGroup);
// clear needs to be tested
id.DataFunctionalities = DataFunctionalities.None;
Assert.AreEqual(DataFunctionalities.None, id.DataFunctionalities);
Assert.AreEqual(DataGroups.Audio, id.DataGroup, "Cleared incorrectly.");
id.DataGroup = DataGroups.None;
Assert.AreEqual(DataGroups.None, id.DataGroup);
}
}
}

View File

@ -87,7 +87,7 @@ namespace NTwain.Data
Buffer.BlockCopy(part, 0, array, 2, 2);
var converted = BitConverter.ToUInt32(array, 0);
return new TWOneValue
{
ItemType = ItemType.Fix32,
@ -1685,7 +1685,7 @@ namespace NTwain.Data
public DataGroups DataGroup
{
get { return (DataGroups)(_supportedGroups & 0xffff); }
set { _supportedGroups |= (uint)value; }
set { _supportedGroups = ((uint)value & 0xffff) | (0xffff0000 & _supportedGroups); }
}
/// <summary>
@ -1710,7 +1710,7 @@ namespace NTwain.Data
public DataFunctionalities DataFunctionalities
{
get { return (DataFunctionalities)(_supportedGroups & 0xffff0000); }
set { _supportedGroups |= (uint)value; }
set { _supportedGroups = ((uint)value & 0xffff0000) | (0x0000ffff & _supportedGroups); }
}
/// <summary>