You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

41 lines
1.3 KiB

using Rhino.Mocks;
using Sevomin.Models;
using Sevomin.Models.Repositories;
using System.Collections.Generic;
using System.Linq;
namespace Sevomin.Tests
{
public class FakeJobRepository
{
private static IJobRepository _JobRepository;
private static IQueryable<Job> _Job;
static FakeJobRepository()
{
Init();
}
internal static void Init()
{
_Job = (new List<Job>() {
new Job{ Id = 1, AvalinId = "a", Avalin = new Avalin(){Id = "a", UserName="test"}, JobParameters = new List<JobParameter>(){new JobParameter{Id = 4}}},
new Job{ Id = 3, AvalinId = "b", Avalin = new Avalin(){Id = "b", UserName="B"}, JobParameters = new List<JobParameter>(){new JobParameter{Id = 4}}}
}).AsQueryable();
_JobRepository = MockRepository.GenerateStub<IJobRepository>();
_JobRepository.Stub(x => x.Find(Arg<long>.Is.Anything))
.WhenCalled(x => x.ReturnValue = _Job.FirstOrDefault(y => y.Id == (long)x.Arguments[0]))
.Return(new Job());
_JobRepository.Stub(x => x.ListAll()).Return(_Job);
}
internal static IJobRepository Instance()
{
return _JobRepository;
}
}
}