예제 #1
0
        public void PushPin_WhenCalled_AddsToPinnedList()
        {
            var recentEntries = new RecentEntryList();

            var localSettingsMock = Mock.Create<ILocalSettingsService>();
            Mock.Arrange(() => localSettingsMock.SaveRecentEntries(Arg.IsAny<string>(), Arg.IsAny<string>()));
            recentEntries.LocalSettingsService = localSettingsMock;

            recentEntries.Add(5, "test", "description");
            recentEntries.PushPin(new RecentEntry(5, "test", "description", recentEntries));
            Assert.AreEqual(recentEntries.PinnedList.Count, 1);
        }
예제 #2
0
        public void UnPushPin_WhenCalled_CallsSave()
        {
            var recentEntries = new RecentEntryList();

            var localSettingsMock = Mock.Create<ILocalSettingsService>();
            var calls = 0;
            Mock.Arrange(() => localSettingsMock.SaveRecentEntries(Arg.IsAny<string>(), Arg.IsAny<string>())).DoInstead(() => calls++);
            
            recentEntries.LocalSettingsService = localSettingsMock;

            recentEntries.Add(5, "description", "test");

            recentEntries.PushPin(new RecentEntry(5, "test", "description", recentEntries));

            recentEntries.UnPushPin(new RecentEntry(5, "ddd", "description", recentEntries));

            Assert.AreEqual(3, calls);
        }
예제 #3
0
        public void RemoveDeletedItem_WhenCalled_Deletes()
        {
            var recentEntries = new RecentEntryList();

            var localSettingsMock = Mock.Create<ILocalSettingsService>();
            Mock.Arrange(() => localSettingsMock.SaveRecentEntries(Arg.IsAny<string>(), Arg.IsAny<string>())).DoInstead(() => { });

            recentEntries.LocalSettingsService = localSettingsMock;

            recentEntries.Add(1, "name1", "description");
            recentEntries.Add(2, "name2", "description");
            recentEntries.Add(3, "name3", "description");
            recentEntries.Add(4, "name4", "description");

            recentEntries.PushPin(recentEntries.UnpinnedList.FirstOrDefault(x => x.Id == 2));
            recentEntries.PushPin(recentEntries.UnpinnedList.FirstOrDefault(x => x.Id == 4));

            recentEntries.RemoveDeletedItem(2);
            recentEntries.RemoveDeletedItem(3);

            Assert.IsNotNull(recentEntries.UnpinnedList.FirstOrDefault(e => e.Id == 1));
            Assert.IsNotNull(recentEntries.PinnedList.FirstOrDefault(e => e.Id == 4));
            Assert.IsNull(recentEntries.PinnedList.FirstOrDefault(e => e.Id == 2));
            Assert.IsNull(recentEntries.UnpinnedList.FirstOrDefault(e => e.Id == 3));
        }