public void ResolveTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null && files.Count >= 2)
            {
                // Get reminder for second file
                TrackedFile file = files[1];

                if (file.ReminderID != -999)
                {
                    Reminder reminder        = file.GetReminder();
                    DateTime defaultDateTime = new DateTime();
                    if (reminder.ResolvedOn == defaultDateTime)
                    {
                        // Verify the reminder for this file is not resolved.
                        Assert.AreEqual(defaultDateTime, reminder.ResolvedOn);

                        // Call reminder Resolve for this reminder to clear
                        // the reminder.
                        reminder.Resolve();


                        // Verify the reminder for this file is resolved.
                        Assert.AreNotEqual(defaultDateTime, reminder.ResolvedOn);
                    }
                }
            }
        }
        public void RemoveMemoTest()
        {
            string defaultMemo = "Description for memo test reminder";
            string removedMemo = "";

            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                TrackedFile file = files[0];

                // Store the current file memo
                string currentMemo = file.FileMemo ?? "";

                // Update the file to default text
                file.UpdateMemo(defaultMemo);

                // Verify file has the default memo text
                Assert.AreEqual(defaultMemo, file.FileMemo);

                // Remove the file memo
                file.RemoveMemo();

                // Verify the file memo has been removed
                Assert.AreEqual(removedMemo, file.FileMemo);

                // Update the file memo to the original memo text
                file.UpdateMemo(currentMemo);

                // Verify the file memo has the original memo text
                Assert.AreEqual(currentMemo, file.FileMemo);
            }
        }
        public void GetLinksTest()
        {
            // Test Parameters
            bool linksFound = false;

            // Get tracked files
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            // Verify there are tracked files returned
            Assert.IsNotNull(files, "No tracked files found.");

            // Search for a link in the tracked files
            foreach (var file in files)
            {
                if (file.GetLinks() != null)
                {
                    // Get Links Successful and break
                    linksFound = true;
                    break;
                }
            }

            // Verify a link was found with one of the files
            Assert.IsTrue(linksFound, "No links found in the tracked files.");
        }
        public void GetFilesTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                // Get reminder for first file
                TrackedFile file     = files[0];
                Reminder    reminder = file.GetReminder();

                // Get the count for all the files that
                // have this reminder.
                int reminderCount = 0;

                foreach (var f in files)
                {
                    if (f.ReminderID == reminder.ReminderID)
                    {
                        reminderCount++;
                    }
                }

                // Call reminder GetFiles for this reminder to get the
                // list of files with this reminder.
                List <TrackedFile> reminderfileList = reminder.GetFiles();

                // Verify the counts are the same
                Assert.AreEqual(reminderCount, reminderfileList.Count);
            }
        }
        public void GetReminderTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                // Test reminders for first file
                TrackedFile file     = files[0];
                Reminder    reminder = file.GetReminder();

                //Assert for file 1
                Assert.AreEqual(1, reminder.ReminderID);
                Assert.AreEqual("First reminder", reminder.Name);
                Assert.AreEqual("Description for first reminder", reminder.Memo);
            }
        }
        public void GetInfoTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                TrackedFile first        = files[0];
                string      originalName = first.Filename;
                string      newName      = "Something different than what we know it is";
                first.Filename = newName; // only updating the in-memory object; not database
                first.GetInfo();          // refresh object information from database
                string actual = first.Filename;
                Assert.AreNotEqual(newName, actual);
                Assert.AreEqual(originalName, actual);
            }
        }
        public void StartTrackingTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                TrackedFile file = files[0];

                file.StopTracking();

                Assert.AreNotEqual(new DateTime(), file.TrackingDisabledOn);

                file.StartTracking();

                Assert.AreEqual(new DateTime(), file.TrackingDisabledOn);
            }
        }
        public void GetHistoryTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                // File 1 history
                TrackedFile file = files[0];

                List <Event> events = file.GetHistory();
                if (events != null)
                {
                    Assert.AreEqual(1, events.Count);
                    Assert.AreEqual("First file added to system", events[0].Description);

                    // File 2 history
                    file   = files[1];
                    events = file.GetHistory();
                    Assert.IsNull(events);
                }
            }
        }
        public void RemoveMemoTest()
        {
            string defaultMemo = "Description for memo test reminder";
            string removedMemo = "";

            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                // Get reminder for first file
                TrackedFile file = files[0];

                if (file.ReminderID != -999)
                {
                    Reminder reminder = file.GetReminder();

                    // Store reminder memo value
                    string memo = reminder.Memo ?? "";

                    // Update reminder memo value to default text
                    reminder.UpdateMemo(defaultMemo);

                    // Verify reminder has default memo text
                    Assert.AreEqual(defaultMemo, reminder.Memo);

                    // Remove the reminder memo
                    reminder.RemoveMemo();

                    // Verify the reminder memo has been removed
                    Assert.AreEqual(removedMemo, reminder.Memo);

                    // Update reminder memo with the original memo text
                    reminder.UpdateMemo(memo);

                    // Verify the reminder has the original memo text
                    Assert.AreEqual(memo, reminder.Memo);
                }
            }
        }
        public void UpdateInfoTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                // Get one of the files and modify the file name
                TrackedFile first       = files[0];
                string      fileName    = first.Filename;
                string      newFileName = fileName + "TestName";
                first.Filename = newFileName;

                // Verify the filename has been changed for the object
                Assert.AreNotEqual(fileName, first.Filename);
                Assert.AreEqual(newFileName, first.Filename);

                // Update Info for the object
                first.UpdateInfo();

                // Verify info was updated for the object
                Assert.AreEqual(fileName, first.Filename);
                Assert.AreNotEqual(newFileName, first.Filename);
            }
        }
        public void RemoveFilesTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null && files.Count >= 3)
            {
                // Get reminder for third file
                TrackedFile file = files[2];

                if (file.ReminderID != -999)
                {
                    Reminder reminder = file.GetReminder();


                    // Call reminder GetFiles for this reminder to get the
                    // list of files with this reminder.
                    List <TrackedFile> reminderfileList = reminder.GetFiles();

                    // Create an int list containing the third file id to remove the reminder.
                    List <int> removeList = new List <int>()
                    {
                        file.FileID
                    };

                    // Remove the reminder for the files in the remove list.
                    reminder.RemoveFiles(removeList);

                    // Get the list of files assigned the reminder that was removed from the third file.
                    List <TrackedFile> reminderfileListAfterRemove = reminder.GetFiles();

                    // Verify the after remove file count list matches the before remove file
                    // count list minus the number of files in the remove list.
                    Assert.AreEqual(reminderfileListAfterRemove.Count, reminderfileList.Count - removeList.Count);
                }
            }
        }
        public void JoinTest()
        {
            // Get file link for link memo id = 1
            int      linkMemoId = 1;
            FileLink fl         = LinkManager.GetLink(linkMemoId);

            // Get the files for file link
            List <TrackedFile> linkedFiles = fl.GetFiles();

            // Verify at least one file is returned
            Assert.IsNotNull(linkedFiles);

            // Get all files
            List <TrackedFile> allFiles = FileManagerDAL.GetFiles();

            // Find a file not in the MemoId = 1 list
            TrackedFile joinFile = null;

            // Get a list of the file IDs of the linked files
            List <int> linkedFileIDs = new List <int>();

            foreach (var file in linkedFiles)
            {
                linkedFileIDs.Add(file.FileID);
            }

            //
            foreach (var file in allFiles)
            {
                if (!linkedFileIDs.Contains(file.FileID))
                {
                    joinFile = file;
                    break;
                }
            }

            // Join file if we have found one
            if (joinFile != null)
            {
                // Join file
                fl.Join(joinFile.FileID);

                // Reteieve file list
                linkedFiles = fl.GetFiles();

                // Fill linedFileIDs with new file ID list
                linkedFileIDs.Clear();
                foreach (var file in linkedFiles)
                {
                    linkedFileIDs.Add(file.FileID);
                }

                // Verify joined file exists in the list
                Assert.IsTrue(linkedFileIDs.Contains(joinFile.FileID));

                // Remove joined file
                fl.RemoveFiles(new List <int> {
                    joinFile.FileID
                });
            }
        }