Пример #1
0
        public void Loaded_WhenConfigurationPresent_LoadsConfiguration()
        {
            var config = new[] { 1, 100, 150, 200, 250, 300, 350, 400, 450, 500 };
            var properties = new MockPropertiesService
            {
                ConfigurationFile = config
            };

            var viewModel = new MainWindowViewModel(new MockInteractionService(), new MockComicService(new XKCDComic(500)), properties);
            viewModel.LoadedCommand.ExecuteAsync(null).Wait();

            Assert.AreEqual(viewModel.Comics.Count, config.Length);
            Assert.IsTrue(viewModel.Comics.Select(x => x.Number).OrderBy(x => x).SequenceEqual(config));
        }
Пример #2
0
        public void Loaded_WhenLoadCurrentIsTrue_LoadsCurrent()
        {
            var current = new XKCDComic(500);
            var properties = new MockPropertiesService
            {
                LoadCurrent = true
            };

            var viewModel = new MainWindowViewModel(new MockInteractionService(), new MockComicService(current), properties);
            viewModel.LoadedCommand.ExecuteAsync(null).Wait();

            Assert.AreEqual(viewModel.Comics.Count, 1);
            Assert.IsTrue(viewModel.Comics.Contains(current));
        }
Пример #3
0
        public void Closed_Normal_SavesConfigurationFile()
        {
            IEnumerable<XKCDComic> allComics = new[]
            {
                new XKCDComic(50), new XKCDComic(100), new XKCDComic(150),
                new XKCDComic(200), new XKCDComic(250), new XKCDComic(300)
            };

            var properties = new MockPropertiesService();

            var viewModel = new MainWindowViewModel(new MockInteractionService(), new MockComicService(null), properties);

            foreach (var comic in allComics) viewModel.Comics.Add(comic);

            viewModel.ClosedCommand.ExecuteAsync(null).Wait();

            Assert.IsTrue(properties.ConfigurationFile.SequenceEqual(allComics.Select(x => x.Number)));
        }