示例#1
0
        /// <summary>
        /// Initialize db with some test data
        /// </summary>
        /// <param name="context"></param>
        protected override void Seed(KenDoContext context)
        {
            var tasks = MyTask.GenerateSampleData();

            tasks.ForEach(t => context.MyTasks.Add(t));
            context.SaveChanges();
        }
示例#2
0
        public void GetTasks_ShouldReturnAllTasks()
        {
            var context     = new TestKenDoContext();
            var sampleTasks = MyTask.GenerateSampleData();

            foreach (var t in sampleTasks)
            {
                context.MyTasks.Add(t);
            }

            var controller = new TasksController(context);
            var result     = controller.GetTasks() as OkNegotiatedContentResult <TaskDto[]>;

            Assert.IsNotNull(result);
            Assert.AreEqual(sampleTasks.Count, result.Content.Length);
        }