Example #1
0
        public void Index_Returns_Users_Notes_Sorted_By_DueDate()
        {
            // Arrange - create the mock repo and its data
            var context = new TestContext();

            context.Notes.Add(new Note()
            {
                Id = 1, Title = "Note 1", DueDate = DateTime.Parse("02-01-17"), User = user
            });
            context.Notes.Add(new Note()
            {
                Id = 2, Title = "Note 2", DueDate = DateTime.Parse("01-01-17"), User = user
            });
            context.Notes.Add(new Note()
            {
                Id = 3, Title = "Note 3", DueDate = DateTime.Parse("03-01-17"), User = user2
            });

            // Arrange - create the controller
            NoteController target = new NoteController(context)
            {
                GetUserId = () => user.Id
            };

            // Act
            ViewResult         vr    = (ViewResult)target.StudyList(null);
            StudyListViewModel model = (StudyListViewModel)vr.Model;

            Note[] notes = model.Notes.ToArray();

            // Assert
            Assert.AreEqual(2, notes.Length);
            Assert.AreEqual(2, notes[0].Id);
            Assert.AreEqual(1, notes[1].Id);
        }
Example #2
0
 public virtual void SetStudyList(StudyListViewModel list)
 {
     _studyList = list;
     _studyList.SelectionChanged += _studyList_SelectionChanged;
     if (StudyList.SelectedStudy != null)
     {
         Available = true;
     }
     else
     {
         Available = false;
     }
 }
Example #3
0
        // GET: Note
        public ActionResult StudyList(string notebook)
        {
            string curUser = GetUserId();
            var    model   = new StudyListViewModel
            {
                Notes = db.Notes
                        .Include(note => note.Resources)
                        .Include(note => note.User)
                        .Where(note => note.User.Id == curUser)
                        .Where(note => notebook == null || note.Notebook == notebook)
                        .OrderBy(note => note.DueDate)
                        .ToList(),
                CurrentNotebook = notebook
            };

            return(View(model));
        }
Example #4
0
        /// <summary>
        /// Note: you must call Initialize() after new entity.!
        /// </summary>
        public StudySelectionCtrl()
        {
            InitializeComponent();

            _studyListViewModel = new StudyListViewModel(SeriesDescriptionDisplayMode.ShowSeriesDescription)
            {
                AllowSelectionCrossStudies = true, StudyListContextMenuVM = null
            };

            _studyListViewModel.SeriesSelectionChangedEvent += OnSeriesSelectionChange;

            //Action<SeriesItemChangedType, SeriesTreeViewItemModel> StudyListViewModel_SeriesItemChanged;
            _studyListViewModel.SeriesItemChanged += OnStudyListViewModel_SeriesItemChanged;

            filmingStudyTree.DataContext = _studyListViewModel;

            filmingStudyTree.SupportMultiSelection = true;
            var dict = AppNLSHelper.AppCommonNLSResource;

            if (dict != null)
            {
                filmingStudyTree.Resources.MergedDictionaries.Add(dict);
            }
            // System.Diagnostics.Debugger.Launch();
            filmingStudyTree.CanUpdateScroll    = true;
            filmingStudyTree.SeriesDoubleClick += FilmingStudyTreeOnSeriesDoubleClick;
            //filmingStudyTree.AllowDrop = true;
            //   filmingStudyTree.PreviewDrop +=new DragEventHandler(filmingStudyTree_PreviewDrop);
            filmingStudyTree.AddHandler(TreeViewMultipleDragDropHelper.OnDropAcceptedEvent,
                                        new SelectedSeriesListEventHandler(HandleStudyListDropEvent));

            HandleSelectionChanged();

            //adjust content location of Button
            //var children = GetChildObjects<TextBlock>(btnLoad, typeof (TextBlock));
            //if (children.Count == 0) return;

            //var textBlock = children.FirstOrDefault();
            //if(textBlock != null)
            //    textBlock.Margin = new Thickness(0, 0, 0, 1);
//#if DEBUG
//            InitCompareBtn();
//#endif
        }
Example #5
0
        public void Can_Filter_By_Notebook()
        {
            // Arrange - create the repo
            var context = new TestContext();

            context.Notes.Add(new Note {
                Id = 1, Title = "Note 1", Notebook = "NB1", User = user
            });
            context.Notes.Add(new Note {
                Id = 2, Title = "Note 2", Notebook = "NB2", User = user
            });
            context.Notes.Add(new Note {
                Id = 3, Title = "Note 3", Notebook = "NB1", User = user
            });
            context.Notes.Add(new Note {
                Id = 4, Title = "Note 4", Notebook = "NB2", User = user
            });
            context.Notes.Add(new Note {
                Id = 5, Title = "Note 5", Notebook = "NB3", User = user
            });

            // Arrange - create the controller
            NoteController target = new NoteController(context)
            {
                GetUserId = () => user.Id
            };

            // Act
            ViewResult         vr    = (ViewResult)target.StudyList("NB2");
            StudyListViewModel model = (StudyListViewModel)vr.Model;

            Note[] notes = model.Notes.ToArray();

            // Assert
            Assert.AreEqual(2, notes.Length);
            Assert.IsTrue(notes[0].Title == "Note 2" && notes[0].Notebook == "NB2");
            Assert.IsTrue(notes[1].Title == "Note 4" && notes[0].Notebook == "NB2");
        }