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

10 years ago
  1. using Rhino.Mocks;
  2. using Sevomin.Models;
  3. using Sevomin.Models.Repositories;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. namespace Sevomin.Tests
  7. {
  8. public class FakeJobRepository
  9. {
  10. private static IJobRepository _JobRepository;
  11. private static IQueryable<Job> _Job;
  12. static FakeJobRepository()
  13. {
  14. Init();
  15. }
  16. internal static void Init()
  17. {
  18. _Job = (new List<Job>() {
  19. new Job{ Id = 1, AvalinId = "a", Avalin = new Avalin(){Id = "a", UserName="test"}, JobParameters = new List<JobParameter>(){new JobParameter{Id = 4}}},
  20. new Job{ Id = 3, AvalinId = "b", Avalin = new Avalin(){Id = "b", UserName="B"}, JobParameters = new List<JobParameter>(){new JobParameter{Id = 4}}}
  21. }).AsQueryable();
  22. _JobRepository = MockRepository.GenerateStub<IJobRepository>();
  23. _JobRepository.Stub(x => x.Find(Arg<long>.Is.Anything))
  24. .WhenCalled(x => x.ReturnValue = _Job.FirstOrDefault(y => y.Id == (long)x.Arguments[0]))
  25. .Return(new Job());
  26. _JobRepository.Stub(x => x.ListAll()).Return(_Job);
  27. }
  28. internal static IJobRepository Instance()
  29. {
  30. return _JobRepository;
  31. }
  32. }
  33. }