LCOV - code coverage report
Current view: top level - Cqrs/Services - UnitOfWorkService.cs Hit Total Coverage
Test: doc-coverage.info Lines: 2 4 50.0 %
Date: 2017-07-26

          Line data    Source code
       1             : using Cqrs.Domain;
       2             : 
       3             : namespace Cqrs.Services
       4             : {
       5             :         public class UnitOfWorkService<TAuthenticationToken> : IUnitOfWorkService
       6           0 :         {
       7             :                 protected IUnitOfWork<TAuthenticationToken> UnitOfWork { get; private set; }
       8             : 
       9             :                 protected object Committer { get; private set; }
      10             : 
      11           0 :                 public UnitOfWorkService(IUnitOfWork<TAuthenticationToken> unitOfWork)
      12             :                 {
      13             :                         UnitOfWork = unitOfWork;
      14             :                 }
      15             : 
      16             :                 /// <summary>
      17             :                 /// Informs the service of the object that will be committing the <see cref="UnitOfWork"/>.
      18             :                 /// </summary>
      19             :                 /// <returns>
      20             :                 /// true if the provided <paramref name="commiter"/> is accepted as the committer, false otherwise.
      21             :                 /// </returns>
      22           1 :                 public bool SetCommitter(object commiter)
      23             :                 {
      24             :                         if (Committer != null)
      25             :                                 return false;
      26             : 
      27             :                         Committer = commiter;
      28             :                         return true;
      29             :                 }
      30             : 
      31             :                 /// <summary>
      32             :                 /// Commits the <see cref="UnitOfWork"/> if the provided <paramref name="commiter"/> is the <see cref="Committer"/>.
      33             :                 /// </summary>
      34             :                 /// <returns>
      35             :                 /// true if the provided <paramref name="commiter"/> is the <see cref="Committer"/>, false otherwise.
      36             :                 /// </returns>
      37           1 :                 public bool Commit(object commiter)
      38             :                 {
      39             :                         if (Committer != commiter)
      40             :                                 return false;
      41             : 
      42             :                         UnitOfWork.Commit();
      43             :                         return true;
      44             :                 }
      45             :         }
      46             : }

Generated by: LCOV version 1.10