2014-04-21 04:57:38 +08:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2014-04-03 07:01:21 +08:00
|
|
|
|
using NTwain.Data;
|
2014-04-21 04:57:38 +08:00
|
|
|
|
using NTwain.Internals;
|
|
|
|
|
using System;
|
2014-04-03 07:01:21 +08:00
|
|
|
|
|
|
|
|
|
namespace NTwain.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class TwainSessionTests
|
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
[ExpectedException(typeof(TwainStateException), "State check failed to throw.")]
|
|
|
|
|
public void VerifyState_Throws_When_State_Is_Enforced()
|
|
|
|
|
{
|
2014-04-15 07:04:48 +08:00
|
|
|
|
ITwainStateInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
2014-04-03 07:01:21 +08:00
|
|
|
|
session.EnforceState = true;
|
2014-04-04 19:25:11 +08:00
|
|
|
|
session.ChangeState(4, false);
|
2014-04-03 07:01:21 +08:00
|
|
|
|
|
|
|
|
|
session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void VerifyState_No_Throws_When_State_Is_Not_Enforced()
|
|
|
|
|
{
|
2014-04-15 07:04:48 +08:00
|
|
|
|
ITwainStateInternal session = new TwainSession(TWIdentity.Create(DataGroups.Image, new Version(1, 0), "test", "test", "test", "test"));
|
2014-04-03 07:01:21 +08:00
|
|
|
|
session.EnforceState = false;
|
2014-04-04 19:25:11 +08:00
|
|
|
|
session.ChangeState(4, false);
|
2014-04-03 07:01:21 +08:00
|
|
|
|
|
|
|
|
|
session.VerifyState(6, 6, DataGroups.Image, DataArgumentType.ImageNativeXfer, Message.Get);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|