Table of Contents

Class AutomatedTestsWithData

Namespace
CMS.Tests
Assembly
CMS.Tests.dll

Base class for automated tests with data support

public abstract class AutomatedTestsWithData : AutomatedTests
Inheritance
object
AutomatedTestsWithData
Derived
Inherited Members
Extension Methods

Constructors

AutomatedTestsWithData()

protected AutomatedTestsWithData()

Methods

Fake()

Returns the entry which provides the fake methods from various modules

[Obsolete("Method was not intended for public use and will be removed in the next version. Use method Fake instead.")]
public IFakeMethods Fake()

Returns

IFakeMethods

FakeDynamicObjectType<TInfo, TProvider>(TProvider, string, bool)

Fakes the dynamic data provider.

protected IInfoProviderFake<TInfo, TProvider> FakeDynamicObjectType<TInfo, TProvider>(TProvider providerObject, string objectType, bool fakeInfo = true) where TInfo : AbstractInfoBase<TInfo>, IInfo, new() where TProvider : class, ITestableProvider, new()

Parameters

providerObject TProvider

Provider object.

objectType string

Object type used for registration to ObjectTypeManager.

fakeInfo bool

If true, the info object structure is faked.

Returns

IInfoProviderFake<TInfo, TProvider>

Type Parameters

TInfo
TProvider

Remarks

This API supports the framework infrastructure and is not intended to be used directly from your code.

Exceptions

ArgumentNullException

Thrown when parameters providerObject or objectType are null.

FakeObject<TInfo>(int, Action<TInfo>)

Fakes the data for the given info

public TInfo FakeObject<TInfo>(int id, Action<TInfo> finalizer = null) where TInfo : BaseInfo, IInfo, new()

Parameters

id int

ID of the fake object

finalizer Action<TInfo>

Optional action allowing to seed additional fields.

Returns

TInfo

Type Parameters

TInfo

Remarks

When finalizer is called, provided TInfo object has following properties already set: ObjectID, ObjectCodeName, ObjectGUID, ObjectDisplayName.

Fake<TInfo>(InfoFakeSettings)

Fakes the data for the given info

protected IInfoFake<TInfo> Fake<TInfo>(InfoFakeSettings settings = null) where TInfo : BaseInfo, IInfo, new()

Parameters

settings InfoFakeSettings

Fake settings

Returns

IInfoFake<TInfo>

Type Parameters

TInfo

Fake<TInfo, TProvider>(bool)

Fakes the metadata for TProvider and optionally for TInfo so a test can execute without retrieving the metadata from the database.

An instance of TProvider is created and set as the provider instance. To fake metadata for a provider type not containing a public parameterless constructor, use the Fake<TInfo, TProvider>(TProvider, bool) override while specifying an explicit provider instance.

protected IInfoProviderFake<TInfo, TProvider> Fake<TInfo, TProvider>(bool fakeInfo = true) where TInfo : AbstractInfoBase<TInfo>, IInfo, new() where TProvider : class

Parameters

fakeInfo bool

If true, the info object structure is faked.

Returns

IInfoProviderFake<TInfo, TProvider>

Returns the instance of the faked provider.

Type Parameters

TInfo

Type of info object corresponding to TProvider.

TProvider

Type of info object provider to fake metadata for.

Remarks

To fake metadata of a TInfo provider whose provider class is not generated, use IInfoProvider<TInfo> as the TProvider type.

Exceptions

ArgumentException

Thrown when TProvider does not implement CMS.DataEngine.ITestableProvider.

Fake<TInfo, TProvider>(TProvider, bool)

Fakes the metadata for TProvider and optionally for TInfo so a test can execute without retrieving the metadata from the database.

The providerObject is set as the provider instance.

protected IInfoProviderFake<TInfo, TProvider> Fake<TInfo, TProvider>(TProvider providerObject, bool fakeInfo = true) where TInfo : AbstractInfoBase<TInfo>, IInfo, new() where TProvider : class, ITestableProvider

Parameters

providerObject TProvider

Provider object to be used as the provider.

fakeInfo bool

If true, the info object structure is faked.

Returns

IInfoProviderFake<TInfo, TProvider>

Type Parameters

TInfo

Type of info object corresponding to TProvider.

TProvider

Type of info object provider to fake metadata for.

Exceptions

ArgumentNullException

Thrown when providerObject is null.

GetTestGuid(int)

Gets a predictable test GUID for the given ID

protected static Guid GetTestGuid(int id)

Parameters

id int

Source ID

Returns

Guid

GetVirtualStorageProvider(string, string)

Returns virtual file system provider

protected AbstractStorageProvider GetVirtualStorageProvider(string storageName = "TestVirtualFileSystem", string assemblyName = "CMS.FakeFileSystemStorage")

Parameters

storageName string
assemblyName string

Returns

AbstractStorageProvider

ResetAllFakes()

Resets all fakes registered within the system

public virtual void ResetAllFakes()

TestsWithDataFixtureSetup()

Fixture setup

public void TestsWithDataFixtureSetup()

TestsWithDataFixtureTearDown()

Fixture tear down

public void TestsWithDataFixtureTearDown()

TestsWithDataSetup()

Test setup

public void TestsWithDataSetup()

TestsWithDataTearDown()

Cleans test base (Restore static context)

public void TestsWithDataTearDown()