public void CreateTempCopyExistingBackupTest()
        {
            MockFileSystem mockFileSystem = new MockFileSystem();
            const string BackupPath = @"C:\backup\034234aaljkadfalakdjladfaljkdadfa";
            mockFileSystem.CreateNewFile(BackupPath);

            IMessageAttachment attachment = new MessageAttachment(6, AttachmentType.Image, BackupPath, "IMG_003.JPG");
            AttachmentModel_Accessor target = new AttachmentModel_Accessor(mockFileSystem, attachment);
            string copiedFilePath = target.CreateTempCopy();
            Assert.IsNotNull(copiedFilePath);
        }
        public void CreateTempCopyExistingBackupTest()
        {
            MockFileSystem mockFileSystem = new MockFileSystem();
            const string   BackupPath     = @"C:\backup\034234aaljkadfalakdjladfaljkdadfa";

            mockFileSystem.CreateNewFile(BackupPath);

            IMessageAttachment       attachment = new MessageAttachment(6, AttachmentType.Image, BackupPath, "IMG_003.JPG");
            AttachmentModel_Accessor target     = new AttachmentModel_Accessor(mockFileSystem, attachment);
            string copiedFilePath = target.CreateTempCopy();

            Assert.IsNotNull(copiedFilePath);
        }
        public void ChatConversationImageAttachmentNoLastNameTest()
        {
            MockFileSystem           mockFileSystem         = new MockFileSystem();
            ConversationExporterHtml exporter               = new ConversationExporterHtml(mockFileSystem);
            const string             attachmentPathOriginal = @"C:\fakepath\backup\082308302382";

            StreamWriter sw = new StreamWriter(mockFileSystem.CreateNewFile(attachmentPathOriginal));

            sw.Write("This is attachment file data!");

            var mockContactA = new Mock <IContact>();

            mockContactA.Setup(x => x.FirstName).Returns("James");
            mockContactA.Setup(x => x.LastName).Returns((string)null);
            var mockContactB = new Mock <IContact>();

            mockContactB.Setup(x => x.FirstName).Returns("Peter");
            mockContactB.Setup(x => x.LastName).Returns("Horn");
            ContactList contactList = new ContactList(new IContact[] { mockContactA.Object, mockContactB.Object });

            var mockConversation = new Mock <IConversation>();

            mockConversation.Setup(x => x.AssociatedContacts).Returns(contactList);

            List <IMessageAttachment> attachments = new List <IMessageAttachment>();

            attachments.Add(new MessageAttachment(1, AttachmentType.Image, attachmentPathOriginal, "IMG_0123.JPG"));

            var mockMessage = new Mock <IConversationMessage>();

            mockMessage.Setup(x => x.Attachments).Returns(attachments);
            mockMessage.Setup(x => x.HasAttachments()).Returns(true);

            List <IConversationMessage> messages = new List <IConversationMessage>(new IConversationMessage[] { mockMessage.Object });

            mockConversation.Setup(x => x.GetEnumerator()).Returns(messages.GetEnumerator());
            mockConversation.Setup(x => x.MessageCount).Returns(1);

            MockDisplayOptions mockDisplayOptions = new MockDisplayOptions();
            List <ExportError> exportErrors       = exporter.Export(mockConversation.Object,
                                                                    mockDisplayOptions,
                                                                    @"C:\fakepath\backup\exports\dummy-chat_2014-11-02.html");

            Assert.AreEqual(1, mockFileSystem.DirectoryCount);
            Assert.AreEqual(3, mockFileSystem.FileCount);
            Assert.IsTrue(mockFileSystem.DirectoryExists(@"C:\fakepath\backup\exports\dummy-chat_2014-11-02_attachments"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\dummy-chat_2014-11-02_attachments\IMG_0123.JPG"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\dummy-chat_2014-11-02.html"));
        }
        public void ImageAttachmentFileExistsTest()
        {
            MockFileSystem           mockFileSystem         = new MockFileSystem();
            ConversationExporterHtml exporter               = new ConversationExporterHtml(mockFileSystem);
            const string             attachmentPathOriginal = @"C:\fakepath\backup\082308302382";

            StreamWriter sw = new StreamWriter(mockFileSystem.CreateNewFile(attachmentPathOriginal));

            sw.Write("This is attachment file data!");

            IConversation      conversation       = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.FrankieCoolPicsCell);
            MockDisplayOptions mockDisplayOptions = new MockDisplayOptions();

            // Take up the desired filename so exporter is forced to create a new one.
            mockFileSystem.CreateNewFile(@"C:\fakepath\backup\exports\frankie-coolpics_9-12-2012.html");
            List <ExportError> exportErrors = exporter.Export(conversation, mockDisplayOptions, @"C:\fakepath\backup\exports\frankie-coolpics_9-12-2012.html");

            Assert.AreEqual(0, exportErrors.Count);
            Assert.AreEqual(1, mockFileSystem.DirectoryCount);
            Assert.AreEqual(4, mockFileSystem.FileCount);
            Assert.IsTrue(mockFileSystem.DirectoryExists(@"C:\fakepath\backup\exports\frankie-coolpics_9-12-2012_attachments"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\frankie-coolpics_9-12-2012_attachments\IMG_0036.JPG"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\frankie-coolpics_9-12-2012 (2).html"));
        }
        public void SaveToFileTest()
        {
            const string backupFilename = @"C:\backup\1";
            const string outputFilename = @"C:\Documents\abc.jpg";

            MockFileSystem mockFileSystem = new MockFileSystem();
            Stream backupFile = mockFileSystem.CreateNewFile(backupFilename);
            StreamWriter sw = new StreamWriter(backupFile);
            sw.Write("this is dummy data in the backup file");

            IMessageAttachment attachment = new MessageAttachment(5, AttachmentType.Image, backupFilename, "abc.jpg");
            AttachmentModel_Accessor target = new AttachmentModel_Accessor(mockFileSystem, attachment);
            target.SaveToFile(outputFilename);

            Assert.AreEqual(2, mockFileSystem.FileCount);
            Assert.IsTrue(mockFileSystem.FileExists(outputFilename));
        }
        public void SaveToFileTest()
        {
            const string backupFilename = @"C:\backup\1";
            const string outputFilename = @"C:\Documents\abc.jpg";

            MockFileSystem mockFileSystem = new MockFileSystem();
            Stream         backupFile     = mockFileSystem.CreateNewFile(backupFilename);
            StreamWriter   sw             = new StreamWriter(backupFile);

            sw.Write("this is dummy data in the backup file");

            IMessageAttachment       attachment = new MessageAttachment(5, AttachmentType.Image, backupFilename, "abc.jpg");
            AttachmentModel_Accessor target     = new AttachmentModel_Accessor(mockFileSystem, attachment);

            target.SaveToFile(outputFilename);

            Assert.AreEqual(2, mockFileSystem.FileCount);
            Assert.IsTrue(mockFileSystem.FileExists(outputFilename));
        }
        public void AudioAttachmentTest()
        {
            MockFileSystem           mockFileSystem = new MockFileSystem();
            ConversationExporterHtml exporter       = new ConversationExporterHtml(mockFileSystem);

            StreamWriter sw = new StreamWriter(mockFileSystem.CreateNewFile(@"C:\fakepath\backup\056798632135464"));

            sw.Write("This is mock audio data!");

            IConversation      conversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.WolfmanJackCell);
            List <ExportError> exportErrors = exporter.Export(conversation, new MockDisplayOptions(), @"C:\fakepath\backup\exports\WolfmanJack_10-25-2014.html");

            Assert.AreEqual(0, exportErrors.Count);
            Assert.AreEqual(1, mockFileSystem.DirectoryCount);
            Assert.AreEqual(4, mockFileSystem.FileCount); // 3 exported files + dummy source attachment
            Assert.IsTrue(mockFileSystem.DirectoryExists(@"C:\fakepath\backup\exports\WolfmanJack_10-25-2014_attachments"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\WolfmanJack_10-25-2014_attachments\audio_icon.png"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\WolfmanJack_10-25-2014_attachments\wolfman_howl.amr"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\WolfmanJack_10-25-2014.html"));
        }
        public void VideoAttachmentTest()
        {
            MockFileSystem           mockFileSystem = new MockFileSystem();
            ConversationExporterHtml exporter       = new ConversationExporterHtml(mockFileSystem);

            StreamWriter sw = new StreamWriter(mockFileSystem.CreateNewFile(@"C:\fakepath\backup\056798632135464"));

            sw.Write("This is attachment file data!");

            IConversation      conversation       = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.JerryCoolVidsCell);
            MockDisplayOptions mockDisplayOptions = new MockDisplayOptions();
            List <ExportError> exportErrors       = exporter.Export(conversation, mockDisplayOptions, @"C:\fakepath\backup\exports\Jerry-Coolvids_9-13-2012.html");

            Assert.AreEqual(0, exportErrors.Count);
            Assert.AreEqual(1, mockFileSystem.DirectoryCount);
            Assert.AreEqual(4, mockFileSystem.FileCount); // 3 exported files + dummy source attachment
            Assert.IsTrue(mockFileSystem.DirectoryExists(@"C:\fakepath\backup\exports\Jerry-Coolvids_9-13-2012_attachments"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\Jerry-Coolvids_9-13-2012_attachments\video_icon.png"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\Jerry-Coolvids_9-13-2012_attachments\VIDEO_0015.MOV"));
            Assert.IsTrue(mockFileSystem.FileExists(@"C:\fakepath\backup\exports\Jerry-Coolvids_9-13-2012.html"));
        }
Beispiel #9
0
        public void ExportMultipleConversationsNameCollisionTest()
        {
            IConversation        conversationCell   = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.DavolaCell);
            IConversation        conversationiPhone = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.DavolaiPhone);
            IConversation        conversationMerged = new MergedConversation(conversationCell, conversationiPhone);
            List <IConversation> conversations      = new List <IConversation>();

            conversations.Add(conversationMerged);

            string filename = "dummy_filename.txt";

            const string   outputPath     = "X:\\backup\\";
            MockFileSystem mockFileSystem = new MockFileSystem();

            mockFileSystem.CreateNewFile(Path.Combine(outputPath, filename));

            ConversationExporterBase exporter = new ConversationExporterPlaintext(mockFileSystem);

            exporter.ExportMultipleConversations(conversations, new MockDisplayOptions(), outputPath, null);
            Assert.AreEqual(2, mockFileSystem.FileCount);
        }