1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2009 Oracle.  All rights reserved.
5 *
6 */
7using System;
8using System.Collections;
9using System.Collections.Generic;
10using System.IO;
11using System.Text;
12using System.Threading;
13using System.Xml;
14using NUnit.Framework;
15using BerkeleyDB;
16
17namespace CsharpAPITest
18{
19	[TestFixture]
20	public class CursorConfigTest
21	{
22		private string testFixtureName;
23		private string testFixtureHome;
24		private string testName;
25
26		[TestFixtureSetUp]
27		public void RunBeforeTests()
28		{
29			testFixtureName = "CursorConfigTest";
30			testFixtureHome = "./TestOut/" + testFixtureName;
31		}
32
33		[Test]
34		public void TestConfig()
35		{
36			testName = "TestConfig";
37			/*
38			 * Configure the fields/properties and see if
39			 * they are updated successfully.
40			 */
41			CursorConfig cursorConfig = new CursorConfig();
42			XmlElement xmlElem = Configuration.TestSetUp(
43			    testFixtureName, testName);
44			Config(xmlElem, ref cursorConfig, true);
45			Confirm(xmlElem, cursorConfig, true);
46		}
47
48		public static void Confirm(XmlElement xmlElement,
49		    CursorConfig cursorConfig, bool compulsory)
50		{
51			Configuration.ConfirmIsolation(xmlElement,
52			    "IsolationDegree", cursorConfig.IsolationDegree,
53			    compulsory);
54			Configuration.ConfirmCachePriority(xmlElement,
55			    "Priority", cursorConfig.Priority,
56			    compulsory);
57			Configuration.ConfirmBool(xmlElement,
58			    "SnapshotIsolation", cursorConfig.SnapshotIsolation,
59			    compulsory);
60			Configuration.ConfirmBool(xmlElement,
61			    "WriteCursor", cursorConfig.WriteCursor,
62			    compulsory);
63		}
64
65		public static void Config(XmlElement xmlElement,
66		    ref CursorConfig cursorConfig, bool compulsory)
67		{
68			Configuration.ConfigIsolation(xmlElement,
69			    "IsolationDegree", ref cursorConfig.IsolationDegree,
70			    compulsory);
71			Configuration.ConfigCachePriority(xmlElement,
72			    "Priority", ref cursorConfig.Priority, compulsory);
73			Configuration.ConfigBool(xmlElement,
74			    "SnapshotIsolation", ref cursorConfig.SnapshotIsolation,
75			    compulsory);
76			Configuration.ConfigBool(xmlElement,
77			    "WriteCursor", ref cursorConfig.WriteCursor,
78			    compulsory);
79		}
80	}
81}
82