-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve test coverage: GetIndexInfo, set boolean column to true and f…
…alse, create EsentException with inner exception, use mock API to test SystemParameters, error-handling for JetCreateIndex2 git-svn-id: https://managedese.svn.codeplex.com/svn@24524 25d8fd2b-6a69-44ad-a716-4a7b2595fe98
- Loading branch information
SND\laurionb_cp
authored and
SND\laurionb_cp
committed
May 29, 2009
1 parent
db27441
commit 29a79c6
Showing
7 changed files
with
282 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2006"> | ||
<TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6" /> | ||
</TestLists> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="SystemParameterTests.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using Microsoft.Isam.Esent.Interop; | ||
using Microsoft.Isam.Esent.Interop.Implementation; | ||
using Microsoft.Isam.Esent.Interop.Vista; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Rhino.Mocks; | ||
|
||
namespace InteropApiTests | ||
{ | ||
/// <summary> | ||
/// Test the SystemParameters class. To avoid changing global parameters | ||
/// this is tested with a mock IJetApi. | ||
/// </summary> | ||
[TestClass] | ||
public class SystemParameterTests | ||
{ | ||
/// <summary> | ||
/// Mock object repository. | ||
/// </summary> | ||
private MockRepository repository; | ||
|
||
/// <summary> | ||
/// The real IJetApi, saved in Setup and restored in Teardown. | ||
/// </summary> | ||
private IJetApi savedApi; | ||
|
||
/// <summary> | ||
/// Mock API object. | ||
/// </summary> | ||
private IJetApi mockApi; | ||
|
||
/// <summary> | ||
/// Initialization method. Setup the mock API. | ||
/// </summary> | ||
[TestInitialize] | ||
public void Setup() | ||
{ | ||
this.savedApi = Api.Impl; | ||
this.repository = new MockRepository(); | ||
this.mockApi = this.repository.DynamicMock<IJetApi>(); | ||
|
||
var mockCapabilities = new JetCapabilities | ||
{ | ||
SupportsLargeKeys = true, | ||
SupportsUnicodePaths = true, | ||
SupportsVistaFeatures = true, | ||
SupportsWindows7Features = true, | ||
}; | ||
SetupResult.For(this.mockApi.Capabilities).Return(mockCapabilities); | ||
|
||
Api.Impl = this.mockApi; | ||
} | ||
|
||
/// <summary> | ||
/// Cleanup after a test. This restores the saved API. | ||
/// </summary> | ||
[TestCleanup] | ||
public void Teardown() | ||
{ | ||
Api.Impl = this.savedApi; | ||
} | ||
|
||
/// <summary> | ||
/// Verify that setting the property sets the system parameter | ||
/// </summary> | ||
[TestMethod] | ||
[Priority(0)] | ||
public void VerifySettingCacheSizeMax() | ||
{ | ||
Expect.Call( | ||
this.mockApi.JetSetSystemParameter( | ||
JET_INSTANCE.Nil, JET_SESID.Nil, JET_param.CacheSizeMax, 64, null)).Return(0); | ||
this.repository.ReplayAll(); | ||
SystemParameters.CacheSizeMax = 64; | ||
this.repository.VerifyAll(); | ||
} | ||
|
||
/// <summary> | ||
/// Verify that setting the property sets the system parameter | ||
/// </summary> | ||
[TestMethod] | ||
[Priority(0)] | ||
public void VerifySettingCacheSize() | ||
{ | ||
Expect.Call( | ||
this.mockApi.JetSetSystemParameter( | ||
JET_INSTANCE.Nil, JET_SESID.Nil, JET_param.CacheSize, 64, null)).Return(0); | ||
this.repository.ReplayAll(); | ||
SystemParameters.CacheSize = 64; | ||
this.repository.VerifyAll(); | ||
} | ||
|
||
/// <summary> | ||
/// Verify that setting the property sets the system parameter | ||
/// </summary> | ||
[TestMethod] | ||
[Priority(0)] | ||
public void VerifySettingCacheSizeMin() | ||
{ | ||
Expect.Call( | ||
this.mockApi.JetSetSystemParameter( | ||
JET_INSTANCE.Nil, JET_SESID.Nil, JET_param.CacheSizeMin, 64, null)).Return(0); | ||
this.repository.ReplayAll(); | ||
SystemParameters.CacheSizeMin = 64; | ||
this.repository.VerifyAll(); | ||
} | ||
|
||
/// <summary> | ||
/// Verify that setting the property sets the system parameter | ||
/// </summary> | ||
[TestMethod] | ||
[Priority(0)] | ||
public void VerifySettingDatabasePageSize() | ||
{ | ||
Expect.Call( | ||
this.mockApi.JetSetSystemParameter( | ||
JET_INSTANCE.Nil, JET_SESID.Nil, JET_param.DatabasePageSize, 4096, null)).Return(0); | ||
this.repository.ReplayAll(); | ||
SystemParameters.DatabasePageSize = 4096; | ||
this.repository.VerifyAll(); | ||
} | ||
|
||
/// <summary> | ||
/// Verify that setting the property sets the system parameter | ||
/// </summary> | ||
[TestMethod] | ||
[Priority(0)] | ||
public void VerifySettingMaxInstances() | ||
{ | ||
Expect.Call( | ||
this.mockApi.JetSetSystemParameter( | ||
JET_INSTANCE.Nil, JET_SESID.Nil, JET_param.MaxInstances, 12, null)).Return(0); | ||
this.repository.ReplayAll(); | ||
SystemParameters.MaxInstances = 12; | ||
this.repository.VerifyAll(); | ||
} | ||
|
||
/// <summary> | ||
/// Verify that setting the property sets the system parameter | ||
/// </summary> | ||
[TestMethod] | ||
[Priority(0)] | ||
public void VerifySettingConfiguration() | ||
{ | ||
Expect.Call( | ||
this.mockApi.JetSetSystemParameter( | ||
JET_INSTANCE.Nil, JET_SESID.Nil, VistaParam.Configuration, 0, null)).Return(0); | ||
this.repository.ReplayAll(); | ||
SystemParameters.Configuration = 0; | ||
this.repository.VerifyAll(); | ||
} | ||
|
||
/// <summary> | ||
/// Verify that setting the property sets the system parameter | ||
/// </summary> | ||
[TestMethod] | ||
[Priority(0)] | ||
public void VerifySettingEnableAdvanced() | ||
{ | ||
Expect.Call( | ||
this.mockApi.JetSetSystemParameter( | ||
JET_INSTANCE.Nil, JET_SESID.Nil, VistaParam.EnableAdvanced, 1, null)).Return(0); | ||
this.repository.ReplayAll(); | ||
SystemParameters.EnableAdvanced = true; | ||
this.repository.VerifyAll(); | ||
} | ||
} | ||
} |