private void CreateCorrectTestData()
        {
            var data = GenerateData();

            context = new Mock <EFDbContext>();
            var mockSet = new Mock <DbSet <SentenceTask> >();

            mockSet.As <IQueryable <SentenceTask> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <SentenceTask> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <SentenceTask> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <SentenceTask> >().Setup(m => m.GetEnumerator()).Returns(() => data.GetEnumerator());
            mockSet.Setup(m => m.Find(It.IsAny <object[]>()))
            .Returns <object[]>((d) =>
            {
                return(data.FirstOrDefault(x => x.SentenceTaskId == (int)d[0]));
            });
            context.Setup(x => x.Set <SentenceTask>()).Returns(mockSet.Object);
            rep = new SentenceTaskRepository(context.Object);
        }
        private void CreateCorrectTestData()
        {
            var data = GenerateData();
            var _rep = new Mock <ISentenceTaskRepository>();

            _rep.Setup(x => x.Add(It.IsAny <SentenceTask>()))
            .Returns(true);
            _rep.Setup(x => x.Delete(It.IsAny <int>()))
            .Returns <int>(x => x);
            _rep.Setup(x => x.Edit(It.IsAny <SentenceTask>()))
            .Returns(true);
            _rep.Setup(x => x.GetAll())
            .Returns(data);
            _rep.Setup(x => x.Get(It.IsAny <int>()))
            .Returns <int>(x => data.FirstOrDefault());
            _rep.Setup(x => x.GetAllCategories()).Returns(data.GroupBy(x => x.Category).Select(x => x.Key));
            _rep.Setup(x => x.GetByCategory(It.IsAny <string>()))
            .Returns <string>(str => data.Where(x => x.Category.Equals(str)));
            _rep.Setup(x => x.GetTasks(It.IsAny <string>(), It.IsAny <int[]>()))
            .Returns <string, int[]>((str, arr) => data.Where(x => x.Category.Equals(str) && x.SentenceTaskId != arr[0]));
            service = new SentenceTaskService(_rep.Object);
            rep     = _rep.Object;
        }
 public SentenceTaskService(ISentenceTaskRepository _rep)
 {
     rep = _rep;
 }