public void CanGetAllFolders() { var context = Provider.GetContext(); var previousItemsCount = context.Folders.GetAll().Count(); var newItemsCount = RandomValueGenerator.Integer(5, 10); // Add random Folder and add to get its DB id var newFolders = new List <Folder>(); for (var i = 0; i < newItemsCount; i++) { var folder = ModelGenerator.Folder(); folder.Id = context.Folders.Add(folder); newFolders.Add(folder); } var savedItems = context.Folders.GetAll(); var currentItemsCount = savedItems.Count(); // Check to see if number of items retrieved matches Assert.AreEqual(previousItemsCount + newItemsCount, currentItemsCount); // Check if items retreived have correct values foreach (var newFolder in newFolders) { var savedItem = savedItems.Where(i => i.Id == newFolder.Id).SingleOrDefault(); Assert.IsNotNull(savedItems); ModelAssert.AreEqual(newFolder, savedItem); } }
public void CanSaveDocumentFolder() { var context = Provider.GetContext(); // Add some more folders var newFolderIds = new List <int>(); for (var i = 0; i < RandomValueGenerator.Integer(2, 5); i++) { var newFolderId = context.Folders.Add(ModelGenerator.Folder()); newFolderIds.Add(newFolderId); } var newId = context.Documents.Add(ModelGenerator.Document(FolderId)); // Edit existing document name and save var document = context.Documents.GetItem(newId); document.FolderId = newFolderIds.RandomItem(); context.Documents.Save(document); // Get saved document and check values var savedDocument = context.Documents.GetItem(newId); ModelAssert.AreEqual(document, savedDocument); }
public void CannotGetDocumentsForIncorrectFolder() { var context = Provider.GetContext(); var newFolderId = context.Folders.Add(ModelGenerator.Folder()); // Add random document and add to get its DB id var newDocuments = new List <Document>(); for (var i = 0; i < RandomValueGenerator.Integer(5, 10); i++) { var document = ModelGenerator.Document(newFolderId); document.Id = context.Documents.Add(document); newDocuments.Add(document); } // Get items from old folder var savedItems = context.Documents.GetSummaries(FolderId).ToList(); // Check that item for another folder is not retrieved foreach (var newDocument in newDocuments) { var savedItem = savedItems .Where(i => i.Id == newDocument.Id) .SingleOrDefault(); Assert.IsNull(savedItem); } }
public void CanShortenTextByNotTruncatingShortText() { var limit = 50; var textLength = RandomValueGenerator.Integer(30, 40); var newText = TextManipulations.ShortenText(RandomValueGenerator.AlphaNumericText(textLength), limit); Assert.AreEqual(textLength, newText.Length); }
public void CanShortenTextWithSpaces() { var limit = 50; var spacePosition = RandomValueGenerator.Integer(100, 200); var text = $"{RandomValueGenerator.AlphaNumericText(spacePosition)} {RandomValueGenerator.AlphaNumericText(100, 200)}"; var newText = TextManipulations.ShortenText(text, limit); Assert.AreEqual(spacePosition + EllipsisLength, newText.Length); }