CollectionRepository: Adding tests

This commit is contained in:
Zoe Roux
2021-07-31 17:22:55 +02:00
parent 4ae28f2594
commit 0fa73b1d6a
8 changed files with 462 additions and 33 deletions
+14 -5
View File
@@ -234,16 +234,23 @@ namespace Kyoo.Controllers
finally
{
Database.ChangeTracker.LazyLoadingEnabled = lazyLoading;
Database.ChangeTracker.Clear();
}
}
/// <summary>
/// An overridable method to edit relation of a resource.
/// </summary>
/// <param name="resource">The non edited resource</param>
/// <param name="changed">The new version of <see cref="resource"/>. This item will be saved on the databse and replace <see cref="resource"/></param>
/// <param name="resetOld">A boolean to indicate if all values of resource should be discarded or not.</param>
/// <returns></returns>
/// <param name="resource">
/// The non edited resource
/// </param>
/// <param name="changed">
/// The new version of <see cref="resource"/>.
/// This item will be saved on the database and replace <see cref="resource"/>
/// </param>
/// <param name="resetOld">
/// A boolean to indicate if all values of resource should be discarded or not.
/// </param>
protected virtual Task EditRelations(T resource, T changed, bool resetOld)
{
return Validate(resource);
@@ -254,7 +261,9 @@ namespace Kyoo.Controllers
/// It is also called on the default implementation of <see cref="EditRelations"/>
/// </summary>
/// <param name="resource">The resource that will be saved</param>
/// <exception cref="ArgumentException">You can throw this if the resource is illegal and should not be saved.</exception>
/// <exception cref="ArgumentException">
/// You can throw this if the resource is illegal and should not be saved.
/// </exception>
protected virtual Task Validate(T resource)
{
if (typeof(T).GetProperty(nameof(resource.Slug))!.GetCustomAttribute<ComputedAttribute>() != null)