public void AddDuplicateWords_ShouldAddOneAnotherDocToExistingWordDocContainer() { var doc = new Doc() { Name = "789", Content = "hello home" }; doc.WordsOfDoc.Add(new Word() { Term = "home" }); var words = new List <string>() { "hello" }; var documentRepository = new DocumentRepository(_searchContext); documentRepository.AddDuplicateWords(words, doc); var expected = _searchContext.Words.Where(x => x.Term == "hello") .Include(x => x.DocsContainer) .First().DocsContainer; Assert.Equal(3, expected.Count); Assert.Equal("789", expected[2].Name); }
public void AddNewDoc_ShouldAddOneDoc() { var doc = new Doc() { Name = "789", Content = "hello home" }; doc.WordsOfDoc.Add(new Word() { Term = "home" }); var documentRepository = new DocumentRepository(_searchContext); documentRepository.AddNewDoc(doc); documentRepository.AddDuplicateWords(new List <string>(), new Doc()); // For calling SaveChanges() Assert.Equal(3, _searchContext.Docs.Count()); Assert.True(_searchContext.Docs.Any(x => x.Name == "789")); }