public void RemovingAllWords_FromMaster_WillDeleteMasterAsWell(bool oneByOne) { var master = MasterWordsService.GetAll().First(); var book = master.Books.First(); var before = MasterWordsService.GetAll().Count(); var beforeInBook = book.Words.Count(); if (oneByOne) { foreach (var w in master.Words.ToArray()) { WordsService.Remove(w); } } else { WordsService.Remove(master.Words); } var secondMaster = MasterWordsService.GetAll().First(); Assert.AreNotEqual(secondMaster, master); Assert.AreEqual(before - 1, MasterWordsService.GetAll().Count(), "Master count missmatch"); Assert.AreEqual(beforeInBook - 1, book.Words.Count(), "Word in book count missmatch"); }
public void RemovingWord_WithExplanationsAndDefinitions_UdpatesDB() { var before = WordsService.GetAll().Count(); var word = WordsService.GetWordsWithData().First(); WordsService.Remove(word); var after = WordsService.GetAll().Count(); Assert.AreEqual(before - 1, after, "Count missmatch"); }
public void RemovingMasterWord_WillUpdateDB_AndRemoveWordsFromBookAutomatically() { var before = BooksService.GetAllWithData().First().Words.Count(); var word = MasterWordsService.GetAll().First(); WordsService.Remove(word.Words); // removing all words will remove master automatically var newWord = MasterWordsService.GetAll().First(); var after = BooksService.GetAllWithData().First().Words.Count(); Assert.AreNotEqual(word, newWord); Assert.AreEqual(before - 1, after, "Count missmatch"); }
public void RemovingWord_WithNotLoadedMaster_StillWorksFine() { // Arrange var masterA = new MasterWord(); var wordA = new Word(masterA, "Hi", new Language("English")); MasterWordsService.Add(masterA); RefreshServicesAndClearCache(); // Act WordsService.Remove(WordsService.GetAll().WithID(wordA)); // Assert Assert.IsNull(MasterWordsService.Get(masterA.ID), "Master should be destroyed"); Assert.IsNull(WordsService.Get(wordA.ID), "Word should be destroyed"); }
private void RemoveWord(object o) { var word = o as WordViewModel; if (word == null) { return; } var r = ModernDialog.ShowMessage("do you really want to remove word?", "word removing", MessageBoxButton.YesNo); if (r == MessageBoxResult.No) { return; } WordsService.Remove <Word>(word.WordToDisplay); WordsCollection.Remove(word); }
public void RemovingAllWords_DestroysMasterWordAsWell_UsingRemoveRange([Values(true, false)] bool cleanCache) { // Arrange var masterA = new MasterWord(); new Word(masterA, "Hi", new Language("English")); new Word(masterA, "Hola", new Language("Spanish")); MasterWordsService.Add(masterA); if (cleanCache) { RefreshServicesAndClearCache(); } // Act WordsService.Remove(WordsService.GetAll().ToArray()); // Assert masterA = MasterWordsService.Get(masterA.ID); Assert.IsNull(masterA, "Master should be destroyed"); }