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 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 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 CanCallRemoveFolder() { var context = Provider.GetContext(); var newId = context.Folders.Add(ModelGenerator.Folder()); context.Folders.Remove(newId); }
public void CanCallAddFolder() { var context = Provider.GetContext(); var folder = ModelGenerator.Folder(); var newId = context.Folders.Add(folder); Assert.AreNotEqual(0, newId); }
public void CanCallSaveFolder() { var context = Provider.GetContext(); // Get existing item var newId = context.Folders.Add(ModelGenerator.Folder()); var folder = context.Folders.GetItem(newId); // Save it context.Folders.Save(folder); }
public void CanCallGetFolder() { var context = Provider.GetContext(); // Add random Folder and add to get its DB id var folder = ModelGenerator.Folder(); var newId = context.Folders.Add(folder); // See if that id will return an object var savedFolder = context.Folders.GetItem(newId); Assert.IsNotNull(savedFolder); }
public void CanCorrectlyAddFolder() { var context = Provider.GetContext(); // Add random Folder and add to get its DB id var folder = ModelGenerator.Folder(); folder.Id = context.Folders.Add(folder); // See if saved Folder's values are correct var savedFolder = context.Folders.GetItem(folder.Id); ModelAssert.AreEqual(folder, savedFolder); }
public void CanSaveFolderName() { var context = Provider.GetContext(); var newId = context.Folders.Add(ModelGenerator.Folder()); // Edit existing Folder name and save var folder = context.Folders.GetItem(newId); folder.Name = RandomValueGenerator.AlphaNumericText(10, 200); context.Folders.Save(folder); // Get saved Folder and check values var savedFolder = context.Folders.GetItem(newId); ModelAssert.AreEqual(folder, savedFolder); }
public void CanRemoveFolder() { var context = Provider.GetContext(); // Ensure at least one item exists context.Folders.Add(ModelGenerator.Folder()); // Get items var items = context.Folders.GetAll().ToList(); // Call ToList to ensure query runs now // Remove one of those var itemToRemove = items.RandomItem(); context.Folders.Remove(itemToRemove.Id); var savedFolder = context.Folders.GetItem(itemToRemove.Id); var savedItems = context.Folders.GetAll().ToList(); Assert.IsNull(savedFolder); // Ensure one item has been removed Assert.AreEqual(items.Count() - 1, savedItems.Count()); }
public static void ClassInitialize(TestContext testContext) { var context = Provider.GetContext(); DocumentTest.FolderId = context.Folders.Add(ModelGenerator.Folder()); }