public ThreadViewModel(INavigation navigation, IThreadAPI api)
        {
            _api = api;
            _navigation = navigation;
            _threadId = api.Id;
            Posts = new ObservableCollection<Post>();

            Title = CreateScreenTitle();
        }
        public void Setup()
        {
            var navigation = new MockNavigation();
            var threadId = new ThreadId(new BoardId("test"), 123456);
            api = new MockAPI() { Id = threadId };
            thread = new ThreadViewModel(navigation, api);

            thread.Posts.CollectionChanged += (send, arg) =>
            {
                if (arg.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
                    postsCleared = true;
            };
        }
 public FourChanThreadAPI(ThreadId id)
 {
     Id = id;
 }
 public static IThreadAPI CreateThreadAPI(ThreadId id)
 {
     return new FourChanThreadAPI(id);
 }
 public ThreadImageModel(ThreadId threadId)
 {
     Title = "/" + threadId.Board + "/" + threadId.Thread + "/image";
     ThreadId = threadId;
 }
 public void OpenThreadImage(ThreadId threadId, Post selectPost)
 {
     var screen = AddOrSelectScreen(x => x.ThreadId.Equals(threadId), () => new ThreadImageModel(threadId));
     screen.ShowImage(selectPost);
 }
 public void OpenThread(ThreadId threadId)
 {
     AddOrSelectScreen(x => x.ThreadId.Equals(threadId), () => new ThreadViewModel(this, FourChanAPI.CreateThreadAPI(threadId)));
 }
        public void Openning_a_thread_sets_it_as_current()
        {
            var threadId = new Model.ThreadId(new Model.BoardId("g"), 123456);

            Views.ApplicationNavigationViewModel model = new Views.ApplicationNavigationViewModel();
            var prevItems = model.Items.ToList();
            model.OpenThread(threadId);

            var addedScreen = model.Items.Except(prevItems).Single();

            Assert.AreSame(addedScreen, model.CurrentScreen);
        }
        public void Openning_a_thread_again_sets_it_as_current()
        {
            var threadId = new Model.ThreadId(new Model.BoardId("g"), 123456);
            Views.ApplicationNavigationViewModel model = new Views.ApplicationNavigationViewModel();

            model.OpenThread(threadId);
            var boardScreen = model.CurrentScreen;
            model.ItemClicked(model.BoardsScreen);

            model.OpenThread(threadId);

            Assert.AreSame(boardScreen, model.CurrentScreen);
        }
        public void Openning_a_thread_again_doesnt_add_it_again()
        {
            var threadId = new Model.ThreadId(new Model.BoardId("g"), 123456);
            Views.ApplicationNavigationViewModel model = new Views.ApplicationNavigationViewModel();
            model.OpenThread(threadId);

            var prevItems = model.Items.ToList();
            model.OpenThread(threadId);
            var addedScreens = model.Items.Except(prevItems).ToList();

            Assert.AreEqual(0, addedScreens.Count, "Screen was added when it shouldn't be!");
        }
        public void Openning_a_thread_adds_it_to_items()
        {
            var threadId = new Model.ThreadId(new Model.BoardId("g"), 123456);

            Views.ApplicationNavigationViewModel model = new Views.ApplicationNavigationViewModel();
            var prevItems = model.Items.ToList();

            model.OpenThread(threadId);

            var newItems = model.Items.Except(prevItems).ToList();

            Assert.AreEqual(1, newItems.Count, "Not exactly one screen was added");

            var addedScreen = newItems.First();
            Assert.IsInstanceOfType(addedScreen, typeof(ThreadViewModel), "Added screen didn't seem to be correct type!");
            Assert.AreEqual(threadId, (addedScreen as ThreadViewModel).ThreadId, "Added screen didn't seem to have correct id!");
        }
 public void OpenThreadImage(ThreadId _threadId, Post clickedPost)
 {
     throw new NotImplementedException();
 }
 public void OpenThread(ThreadId threadId)
 {
     throw new NotImplementedException();
 }