示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
            }
        }
示例#4
0
        public void CanCallRemoveFolder()
        {
            var context = Provider.GetContext();

            var newId = context.Folders.Add(ModelGenerator.Folder());

            context.Folders.Remove(newId);
        }
示例#5
0
        public void CanCallAddFolder()
        {
            var context = Provider.GetContext();

            var folder = ModelGenerator.Folder();

            var newId = context.Folders.Add(folder);

            Assert.AreNotEqual(0, newId);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
        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());
        }
示例#11
0
        public static void ClassInitialize(TestContext testContext)
        {
            var context = Provider.GetContext();

            DocumentTest.FolderId = context.Folders.Add(ModelGenerator.Folder());
        }