Show / Hide Table of Contents

Class RepositoryTests<TKey, TEntity, TRepository>

Baseline set of tests for any IRepository<TKey, TEntity>. This test base class does not impost a particular test framework (eg. MSTest, NUnit, etc..). Instead, you inherit from this class, then implement the abstract methods as just delegate calls to the corresponding base.*_Impl() methods (unless you wish to provide your own alternative implementation for the corresponding baseline test). Don't forget to decorate the implemented test methods with your framework's test attributes to make them discoverable by the test runner.

Inheritance
System.Object
RepositoryTests<TKey, TEntity, TRepository>
AzureTableRepositoryTests<TContext, TEntity, TRepository>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Ease.Repository.Test
Assembly: Ease.Repository.Test.dll
Syntax
public abstract class RepositoryTests<TKey, TEntity, TRepository>
    where TEntity : TKey, new()
    where TRepository : IRepository<TKey, TEntity>
Type Parameters
Name Description
TKey

They type of the key.

TEntity

The type of the entity.

TRepository

The type of the repository.

Properties

| Improve this Doc View Source

Sut

The system under test (i.e. the repository) with its dependencies injected via TheFixture as FakeItEasy fakes.

Declaration
protected TRepository Sut { get; }
Property Value
Type Description
TRepository
| Improve this Doc View Source

TheFixture

The AutoFixture for the tests.

Declaration
protected IFixture TheFixture { get; }
Property Value
Type Description
AutoFixture.IFixture

Methods

| Improve this Doc View Source

Add_Existing_Entity_And_Get_RoundTrip()

NOTE: For most cases, just implement this as a call to the corresponding base.*_Impl(), and don't forget to apply your test framework's appropriate attributes or other mechanism for decorating test methods.

TODO: Solve the round-trip thing and then re-enable this... but don't force its implementation until then.

Declaration
public virtual Task Add_Existing_Entity_And_Get_RoundTrip()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Add_Existing_Entity_And_Get_RoundTrip_Impl()

Declaration
protected virtual Task Add_Existing_Entity_And_Get_RoundTrip_Impl()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Add_New_Entity_And_Get_By_Key_RoundTrip()

NOTE: For most cases, just implement this as a call to the corresponding base.*_Impl(), and don't forget to apply your test framework's appropriate attributes or other mechanism for decorating test methods.

Declaration
public abstract Task Add_New_Entity_And_Get_By_Key_RoundTrip()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Add_New_Entity_And_Get_By_Key_RoundTrip_Impl()

Declaration
protected virtual Task Add_New_Entity_And_Get_By_Key_RoundTrip_Impl()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Add_New_Entity_And_Get_RoundTrip()

Tests a round-trip of persisting a new entity and then fetching it by its key. NOTE: For most cases, just implement this as a call to the corresponding base.*_Impl(), and don't forget to apply your test framework's appropriate attributes or other mechanism for decorating test methods.

Declaration
public abstract Task Add_New_Entity_And_Get_RoundTrip()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Add_New_Entity_And_Get_RoundTrip_Impl()

Declaration
protected Task Add_New_Entity_And_Get_RoundTrip_Impl()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Add_Sets_Keys()

Tests that the repository's Upsert method sets the key fields to something non-null non-empty. NOTE: For most cases, just implement this as a call to the corresponding base.*_Impl(), and don't forget to apply your test framework's appropriate attributes or other mechanism for decorating test methods.

Declaration
public abstract void Add_Sets_Keys()
| Improve this Doc View Source

Add_Sets_Keys_Impl()

Declaration
protected void Add_Sets_Keys_Impl()
| Improve this Doc View Source

AssertEntitiesAreEquivalent(TEntity, TEntity)

Assert that the result entity is "equivalent" to the reference entity (i.e. ignore non-essential properties during comparison, etc... so that just the "important" properties for equivalence are tested).

Declaration
protected abstract void AssertEntitiesAreEquivalent(TEntity result, TEntity reference)
Parameters
Type Name Description
TEntity result
TEntity reference
| Improve this Doc View Source

AssertKeyFieldsNotNull(TEntity)

Assert that the key fields in the entity aren't null or in "not set" state.

Declaration
protected abstract void AssertKeyFieldsNotNull(TEntity entity)
Parameters
Type Name Description
TEntity entity
| Improve this Doc View Source

AssertRepositoryHasNumEntities(Int32)

Assert that there are num entities stored in the repository.

Declaration
protected abstract void AssertRepositoryHasNumEntities(int num = 0)
Parameters
Type Name Description
System.Int32 num
| Improve this Doc View Source

CompleteUnitOfWorkAsync()

Override and complete the test unit of work.

Declaration
protected abstract Task CompleteUnitOfWorkAsync()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Delete_And_Get_RoundTrip()

NOTE: For most cases, just implement this as a call to the corresponding base.*_Impl(), and don't forget to apply your test framework's appropriate attributes or other mechanism for decorating test methods.

Declaration
public abstract Task Delete_And_Get_RoundTrip()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Delete_And_Get_RoundTrip_Impl()

Declaration
protected virtual Task Delete_And_Get_RoundTrip_Impl()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Delete_By_Key_And_Get_RoundTrip()

NOTE: For most cases, just implement this as a call to the corresponding base.*_Impl(), and don't forget to apply your test framework's appropriate attributes or other mechanism for decorating test methods.

TODO: Solve the round-trip thing and then re-enable this... but don't force its implementation until then.

Declaration
public virtual Task Delete_By_Key_And_Get_RoundTrip()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Delete_By_Key_And_Get_RoundTrip_Impl()

Declaration
protected virtual Task Delete_By_Key_And_Get_RoundTrip_Impl()
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

FreezeDependencies(IFixture)

Freeze any constructor-injected dependencies here so that they may be safely obtained later.

Declaration
protected virtual void FreezeDependencies(IFixture fixture)
Parameters
Type Name Description
AutoFixture.IFixture fixture
| Improve this Doc View Source

ModifyEntity(TEntity)

Make a detectable change to the entity, suitable for round-trip persistence testing.

Declaration
protected abstract void ModifyEntity(TEntity entityToModify)
Parameters
Type Name Description
TEntity entityToModify

The entity to be modified in-place.

| Improve this Doc View Source

NewEntity()

Allocate a new entity with its properties set to non-null non-empty data.

Declaration
protected virtual TEntity NewEntity()
Returns
Type Description
TEntity
| Improve this Doc View Source

NewSimpleKeyFromEntity(TEntity)

Return a simple (i.e. not full-entity type) key given an entity to start with.

Declaration
protected abstract TKey NewSimpleKeyFromEntity(TEntity entity)
Parameters
Type Name Description
TEntity entity

The entity from which to allocate a new simple key instance.

Returns
Type Description
TKey

The new simple key - NOT just the entity returned.

| Improve this Doc View Source

NullifyKeyFields(TEntity)

Nullify the TKey fields of the entity.

Declaration
protected abstract void NullifyKeyFields(TEntity entity)
Parameters
Type Name Description
TEntity entity
| Improve this Doc View Source

SetUp()

A setup step is necessary. NOTE: For most cases, just implement this as a call to the corresponding base.*_Impl(), and don't forget to apply your test framework's appropriate attributes or other mechanism for decorating SetUp methods.

Declaration
public abstract void SetUp()
| Improve this Doc View Source

SetUp_Impl()

Declaration
protected virtual void SetUp_Impl()

Extension Methods

ChangeTrackingExtensions.CurrentState<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX