public void Loads_TodoList_When_Initialized()
        {
            var todoItem = new TodoItem {
                Text = "A TODO"
            };

            using (var dbContext = CreateDbContext())
            {
                dbContext.TodoItems.Add(todoItem);
                dbContext.SaveChanges();
            }

            _target.PropertyChanged += (sender, args) => { Assert.Contains(todoItem.Id, _target.TodoList.Select(t => t.Id)); };

            Assert.PropertyChanged(_target, nameof(_target.TodoList), () =>
                                   _target.Initialize());
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                using (var dbContext = new TodoDbContext())
                {
                    dbContext.Database.Migrate();
                }

                var newTodoItemViewModel = new NewTodoItemViewModel(() => new TodoDbContext());
                NewTodoItemView.DataContext = newTodoItemViewModel;
                var showTodoListViewModel = new ShowTodoListViewModel(() => new TodoDbContext());
                ShowTodoListView.DataContext = showTodoListViewModel;

                showTodoListViewModel.Observe(newTodoItemViewModel);
                showTodoListViewModel.Initialize();

                Resources.Add("RemoveTodoItemCommand", new RemoveTodoItemCommand(() => new TodoDbContext()));
            }
        }