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"));
        }
Example #2
0
        public void ExportMultipleConversationsTest()
        {
            List <IConversation> conversations = new List <IConversation>();

            conversations.Add(DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.ObamaCell));
            conversations.Add(DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.HarryLooseTieCell));

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

            exporter.ExportMultipleConversations(conversations, new MockDisplayOptions(), outputPath, null);

            Assert.IsTrue(mockFileSystem.DirectoryExists(outputPath));
            Assert.AreEqual(2, mockFileSystem.FileCount);
        }
        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"));
        }
        public void ImageAttachmentTest()
        {
            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();
            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(3, 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.html"));
        }