public void Cleanup()
 {
     _repository = null;
     _service = null;
     _tests = null;
     _questions = null;
     _unitOfWork = null;
     MockRepository = null;
 }
        public void Initialize()
        {
            MockRepository = new Mock<IRepository<Test>>();

            var firstQuestion = new Question { QuestionId = 1, Difficulty = Difficulty.Hard, Rating = 5 };
            var secondQuestion = new Question { QuestionId = 2, Difficulty = Difficulty.Hard, Rating = 3 };
            var brief = new Brief { Difficulty = Difficulty.Hard, Rating = 5, QuestionText = "Who let the dog's out ?", Answer = "It wasn't me" };
            var choice = new Choice { Difficulty = Difficulty.Hard, Rating = 5, QuestionText = "Who let the dog's out ?", Choices = "Me,You,All of us all are the culprits", Answers = "Me", IsMultiplechoice = true };

            _questions = new List<Question> { firstQuestion, secondQuestion, brief, choice };
            _user = new UserDetail { Name = "Ashutosh", Password = "******", UserRole = UserRole.Admin, DateOfCreation = DateTime.UtcNow };
            _subject = new Subject { SubjectName = "Mathematics", SubjectCategory = "Advanced" };
            _tests = new List<Test>
                                    {
                                      new Test
                                                {
                                                    TestId = 1,
                                                    DateOfCreation = DateTime.UtcNow,
                                                    Subject = _subject,
                                                    Creator = _user,
                                                    Questions = _questions
                                                },
                                      new Test
                                                {
                                                    TestId = 2,
                                                    DateOfCreation = DateTime.UtcNow,
                                                    Subject = _subject,
                                                    Creator = _user,
                                                    Questions = _questions
                                                }
                                    };
            MockRepository.Setup(_ => _.Query()).Returns(_tests.AsQueryable());
            _test = new Test
                            {
                               TestId = 3,
                               DateOfCreation = DateTime.UtcNow,
                               Subject = _subject,
                               Creator = _user,
                               Questions = _questions
                            };
            MockRepository.Setup(_ => _.Add(_test)).Returns(_test);
            _repository = MockRepository.Object;
            _service = new TestService(_repository, _unitOfWork);
            MockRepository.Setup(_ => _.Query()).Returns(_tests.AsQueryable());
        }