public void ChangesModel_MultipleSourceControlEntries_SomeConflicted() { const string conflictedPrefix = "conflicted-path"; var model = new TestableChangesModel(); model.OnStart(); var changes = new List <IChangeEntry>(); AddEntry(changes, "path1", ChangeEntryStatus.Modified, false); AddEntry(changes, "path2", ChangeEntryStatus.Modified, false); AddEntry(changes, "path3", ChangeEntryStatus.Modified, false); AddEntry(changes, $"{conflictedPrefix}4", ChangeEntryStatus.Modified, false, true); AddEntry(changes, $"{conflictedPrefix}5", ChangeEntryStatus.Modified, false, true); model.UpdateChangeList(changes); var conflictedList = model.GetConflictedEntries(); model.Provider.ConflictedState = true; Assert.IsTrue(model.Conflicted); Assert.AreEqual(2, model.ConflictedCount); Assert.AreEqual(2, conflictedList.Count); Assert.IsFalse(conflictedList[0].All); Assert.IsFalse(conflictedList[1].All); Assert.IsTrue(conflictedList[0].Conflicted); Assert.IsTrue(conflictedList[1].Conflicted); Assert.IsTrue(conflictedList[0].Entry.Path.StartsWith(conflictedPrefix)); Assert.IsTrue(conflictedList[1].Entry.Path.StartsWith(conflictedPrefix)); }
public void ChangesModel_SingleSourceControlEntries_SingleUntoggledResult() { var model = new TestableChangesModel(); model.OnStart(); var changes = BuildChangesList(1); model.UpdateChangeList(changes); var fullList = model.GetAllEntries(); Assert.AreEqual(2, fullList.Count); Assert.IsTrue(fullList[0].All); Assert.IsFalse(fullList[0].Toggled); Assert.IsFalse(fullList[1].All); Assert.IsFalse(fullList[1].Toggled); var toggledList = model.GetToggledEntries(); Assert.AreEqual(0, toggledList.Count); var untoggledList = model.GetUntoggledEntries(); Assert.AreEqual(1, untoggledList.Count); Assert.IsFalse(untoggledList[0].All); Assert.IsFalse(untoggledList[0].Toggled); Assert.AreEqual(0, model.ToggledCount); }
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); }
public void ChangesModel_EmptySourceControlEntries_EmptyResultLists() { var model = new TestableChangesModel(); model.OnStart(); model.UpdateChangeList(new List <IChangeEntry>()); var fullList = model.GetAllEntries(); Assert.AreEqual(1, fullList.Count); Assert.IsTrue(fullList[0].All); Assert.AreEqual(0, model.GetToggledEntries().Count); Assert.AreEqual(0, model.GetUntoggledEntries().Count); Assert.AreEqual(0, model.ToggledCount); }
public void ChangesModel_SearchFilters_CaseInsensitive() { var changes = new List <IChangeEntry>(); AddEntry(changes, "alpha1", ChangeEntryStatus.Modified, false); AddEntry(changes, "alpha2", ChangeEntryStatus.Modified, false); AddEntry(changes, "bravo", ChangeEntryStatus.Modified, false); AddEntry(changes, "charlie", ChangeEntryStatus.Modified, false); AddEntry(changes, "Delta3", ChangeEntryStatus.Modified, false); AddEntry(changes, "delta4", ChangeEntryStatus.Modified, false); AddEntry(changes, "delta5", ChangeEntryStatus.Modified, false); AddEntry(changes, "echo", ChangeEntryStatus.Modified, false); AddEntry(changes, "Foxtrot6", ChangeEntryStatus.Modified, false); AddEntry(changes, "Foxtrot7", ChangeEntryStatus.Modified, false); AddEntry(changes, "golf", ChangeEntryStatus.Modified, false); var dictionary = new Dictionary <string, bool> { ["delta5"] = true, ["Foxtrot6"] = true, ["Foxtrot7"] = true, ["golf"] = true }; var model = new TestableChangesModel(); model.OnStart(); model.SetToggled(dictionary); model.UpdateChangeList(changes); var fullList = model.GetAllEntries(); Assert.AreEqual(changes.Count, model.TotalCount); Assert.AreEqual(changes.Count + 1, fullList.Count); Assert.IsTrue(fullList[0].All); var searchFullList = model.GetAllEntries("alpha"); Assert.AreEqual(2, searchFullList.Count); foreach (var entry in searchFullList) { Assert.IsFalse(entry.All); Assert.IsFalse(entry.Toggled); } var toggledList = model.GetToggledEntries(); Assert.AreEqual(dictionary.Count, toggledList.Count); foreach (var entry in toggledList) { Assert.IsFalse(entry.All); } var searchToggledList = model.GetToggledEntries("fox"); Assert.AreEqual(2, searchToggledList.Count); foreach (var entry in searchToggledList) { Assert.IsTrue(entry.Entry.Path.ToLower().Contains("fox")); Assert.IsFalse(entry.All); Assert.IsTrue(entry.Toggled); } var untoggledList = model.GetUntoggledEntries(); Assert.AreEqual(changes.Count - dictionary.Count, untoggledList.Count); var searchUntoggledList = model.GetUntoggledEntries("Del"); Assert.AreEqual(2, searchUntoggledList.Count); foreach (var entry in searchUntoggledList) { Assert.IsTrue(entry.Entry.Path.ToLower().Contains("del")); Assert.AreNotEqual("delta5", entry.Entry.Path); Assert.IsFalse(entry.All); Assert.IsFalse(entry.Toggled); } Assert.AreEqual(dictionary.Count, model.ToggledCount); }
public void ChangesModel_InitializeFromDictionary_TransfersToggledFlag() { const int entryCount = 5; const int toggledCount = 2; const int toggledIndex1 = 0; const int toggledIndex2 = entryCount / 2 + 1; const int untoggledIndex = entryCount - 1; var changes = BuildChangesList(entryCount); var dictionary = new Dictionary <string, bool>(); changes.ForEach((x) => dictionary[x.Path] = false); dictionary[changes[toggledIndex1].Path] = true; dictionary[changes[toggledIndex2].Path] = true; dictionary[changes[untoggledIndex].Path] = false; var model = new TestableChangesModel(); model.OnStart(); model.SetToggled(dictionary); model.UpdateChangeList(changes); var 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.Entry.Path == changes[toggledIndex1].Path || entry.Entry.Path == changes[toggledIndex2].Path) { Assert.IsTrue(entry.Toggled); } else { Assert.IsFalse(entry.Toggled); } } var toggledList = model.GetToggledEntries(); Assert.AreEqual(toggledCount, toggledList.Count); foreach (var entry in toggledList) { Assert.IsTrue(entry.Entry.Path == changes[toggledIndex1].Path || entry.Entry.Path == changes[toggledIndex2].Path); Assert.IsFalse(entry.All); Assert.IsTrue(entry.Toggled); } var untoggledList = model.GetUntoggledEntries(); Assert.AreEqual(entryCount - toggledCount, untoggledList.Count); foreach (var entry in untoggledList) { Assert.IsTrue(entry.Entry.Path != changes[toggledIndex1].Path && entry.Entry.Path != changes[toggledIndex2].Path); Assert.IsFalse(entry.All); Assert.IsFalse(entry.Toggled); } }
public void ChangesModel_MultipleSourceControlEntries_UntoggleSingleFromAll() { 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); 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); }