Пример #1
0
        public void ChangesModel_MultipleSourceControlEntries_UntoggleSingleFromAll()
        {
            const int entryCount = 5;

            var model   = new TestableChangesModel();
            var changes = BuildChangesList(entryCount);

            model.UpdateChangeList(changes);

            var fullList = model.GetAllEntries();

            Assert.AreEqual(entryCount + 1, fullList.Count);
            Assert.IsTrue(fullList[0].All);

            model.UpdateEntryToggle(fullList[0].Entry.Path, true);
            var untoggledEntry = fullList[entryCount / 2 + 1];

            model.UpdateEntryToggle(untoggledEntry.Entry.Path, false);
            Assert.IsFalse(untoggledEntry.Toggled);

            fullList = model.GetAllEntries();
            Assert.AreEqual(entryCount + 1, fullList.Count);
            foreach (var entry in fullList)
            {
                if (entry == fullList[0])
                {
                    Assert.IsTrue(entry.All);
                }
                else
                {
                    Assert.IsFalse(entry.All);
                }

                if (entry == untoggledEntry || entry.All)
                {
                    Assert.IsFalse(entry.Toggled);
                }
                else
                {
                    Assert.IsTrue(entry.Toggled);
                }
            }

            var toggledList = model.GetToggledEntries();

            Assert.AreEqual(entryCount - 1, toggledList.Count);
            foreach (var entry in toggledList)
            {
                Assert.IsFalse(entry.All);
                Assert.AreNotEqual(untoggledEntry, entry);
            }

            var untoggledList = model.GetUntoggledEntries();

            Assert.AreEqual(1, untoggledList.Count);
            Assert.AreEqual(untoggledEntry, untoggledList[0]);

            Assert.AreEqual(entryCount - 1, model.ToggledCount);
        }
Пример #2
0
        public void ChangesModel_MultipleSourceControlEntries_ToggleAllIndividually()
        {
            const int entryCount = 5;

            var model = new TestableChangesModel();

            model.OnStart();
            var changes = BuildChangesList(entryCount);

            model.UpdateChangeList(changes);

            var fullList = model.GetAllEntries();

            Assert.AreEqual(entryCount + 1, fullList.Count);
            Assert.IsTrue(fullList[0].All);

            fullList = model.GetAllEntries();
            foreach (var entry in fullList.Where(entry => !entry.All))
            {
                model.UpdateEntryToggle(entry.Entry.Path, true);
            }

            Assert.AreEqual(entryCount + 1, fullList.Count);
            foreach (var entry in fullList)
            {
                if (entry == fullList[0])
                {
                    Assert.IsTrue(entry.All);
                }
                else
                {
                    Assert.IsFalse(entry.All);
                }
                Assert.IsTrue(entry.Toggled);
            }

            var toggledList = model.GetToggledEntries();

            Assert.AreEqual(entryCount, toggledList.Count);
            foreach (var entry in toggledList)
            {
                Assert.IsFalse(entry.All);
            }

            var untoggledList = model.GetUntoggledEntries();

            Assert.AreEqual(0, untoggledList.Count);

            Assert.AreEqual(entryCount, model.ToggledCount);
        }