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.

44 lines
1.3 KiB

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