public void NormalGroupAddTest()
        {
            XmlDocumentGroup xmlDocumentGroup = XmlHelper.GetXmlDocumentGroup(@".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.xml");
            UploadDocumentGroup uploadDocumentGroup = XmlHelper.GetUploadDocumentGroup(xmlDocumentGroup, @".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.zip");

            using (ShimsContext.Create())
            {
                ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);

                CrawlerLog log = new CrawlerLog();
                DocumentGroup documentGroup = new DocumentGroup();
                IRepository fakeRepository = new StubIRepository
                {
                    GetIdentifierString = (identifier) => { return string.Empty; },
                    GetOrCreateCrawlerIdString = (crawlerName) => { return 1; },
                    AddDocumentGroupDocumentGroup = (newDocumentGroup) => { documentGroup = newDocumentGroup; },
                    AddNewLogCrawlerLog = (crawlerLog) => { log = crawlerLog; }
                };

                WcfHost eu = new WcfHost(fakeRepository);
                var msgActual = eu.UploadFile(uploadDocumentGroup);

                // ReturnMessage
                Assert.AreEqual("Ok", msgActual, "Service return message.");

                // AddDocumentGroup
                Assert.AreEqual(xmlDocumentGroup.Identifier, documentGroup.Identifier, "Identifier");
                Assert.AreEqual(1, documentGroup.CrawlerId, "CrawlerId");
                Assert.AreEqual(0, documentGroup.Operation, "Operation");
                Assert.AreEqual(xmlDocumentGroup.Document.Count, documentGroup.Documents.Count, "DocumentsCount");

                // LogAsserts
                Assert.AreEqual(xmlDocumentGroup.Identifier, log.Identifier, "IdentifierLog");
                Assert.AreEqual(true, log.IsSuccess, "IsSuccess");
                Assert.AreEqual(new DateTime(2000, 1, 1), log.LogDate, "LogDate");
                Assert.AreEqual(xmlDocumentGroup.Crawler, log.CrawlerName, "CrawlerNameLog");
                Assert.AreEqual(0, log.Operation, "OperationLog");
            }
        }
        public void ZipXmlValidationTestNull()
        {
            XmlDocumentGroup xmlDocumentGroup = XmlHelper.GetXmlDocumentGroup(@".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.xml");
            UploadDocumentGroup uploadDocumentGroup = XmlHelper.GetUploadDocumentGroup(xmlDocumentGroup, @".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.zip");
            uploadDocumentGroup.Data = null;

            using (ShimsContext.Create())
            {
                ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);

                CrawlerLog log = new CrawlerLog();
                IRepository fakeRepository = new StubIRepository
                {
                    GetIdentifierString = (identifier) => { return string.Empty; },
                    AddNewLogCrawlerLog = (crawlerLog) => { log = crawlerLog; }
                };

                WcfHost eu = new WcfHost(fakeRepository);
                var msgActual = eu.UploadFile(uploadDocumentGroup);
                string msgExpected = "Error: Validation Exception - ZipData length is zero or ZipData is NULL, document idenfier: " + xmlDocumentGroup.Identifier + " and Operation: Add";

                Assert.AreEqual(msgExpected, msgActual, "Service return message.");
                Assert.AreEqual(false, log.IsSuccess, "IsSuccess");
                Assert.AreEqual(new DateTime(2000, 1, 1), log.LogDate, "LogDate");
            }
        }
        public void IdentifierGroupDeleteTestNull()
        {
            XmlDocumentGroup xmlDocumentGroup = XmlHelper.GetXmlDocumentGroup(@".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.xml");
            xmlDocumentGroup.Operation = Operation.Del;
            UploadDocumentGroup uploadDocumentGroup = XmlHelper.GetUploadDocumentGroup(xmlDocumentGroup, @".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.zip");
            uploadDocumentGroup.Data = null;

            using (ShimsContext.Create())
            {
                ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);

                string ident = string.Empty;
                CrawlerLog log = new CrawlerLog();
                DocumentGroup documentGroup = new DocumentGroup();
                IRepository fakeRepository = new StubIRepository
                {
                    GetIdentifierString = (identifier) => { return string.Empty; },
                    GetOrCreateCrawlerIdString = (crawlerName) => { return 1; },
                    AddDocumentGroupDocumentGroup = (newDocumentGroup) => { documentGroup = newDocumentGroup; },
                    DeleteDocumentGroupString = (identifier) => { ident = identifier; return 1; },
                    AddNewLogCrawlerLog = (crawlerLog) => { log = crawlerLog; }
                };

                WcfHost eu = new WcfHost(fakeRepository);
                var msgActual = eu.UploadFile(uploadDocumentGroup);
                string msgExpected = "Error: Validation Exception - No document idenfier: " + xmlDocumentGroup.Identifier + " .You can't use Operation: Del";

                // ReturnMessage
                Assert.AreEqual(msgExpected, msgActual, "Service return message.");

                // LogAsserts
                Assert.AreEqual(xmlDocumentGroup.Identifier, log.Identifier, "IdentifierLog");
                Assert.AreEqual(false, log.IsSuccess, "IsSuccess");
                Assert.AreEqual(new DateTime(2000, 1, 1), log.LogDate, "LogDate");
                Assert.AreEqual(xmlDocumentGroup.Crawler, log.CrawlerName, "CrawlerNameLog");
                Assert.AreEqual(2, log.Operation, "OperationLog");
            }
        }
        public void FormatXmlValidationTestInvalid()
        {
            XmlDocumentGroup xmlDocumentGroup = XmlHelper.GetXmlDocumentGroup(@".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.xml");
            xmlDocumentGroup.Format = "application/badapplication";
            UploadDocumentGroup uploadDocumentGroup = XmlHelper.GetUploadDocumentGroup(xmlDocumentGroup, @".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.zip");

            using (ShimsContext.Create())
            {
                ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);

                CrawlerLog log = new CrawlerLog();
                IRepository fakeRepository = new StubIRepository
                {
                    GetIdentifierString = (identifier) => { return string.Empty; },
                    AddNewLogCrawlerLog = (crawlerLog) => { log = crawlerLog; }
                };

                WcfHost eu = new WcfHost(fakeRepository);
                var msgActual = eu.UploadFile(uploadDocumentGroup);
                string msgExpected = "Error: Validation Exception - The 'format' attribute has an invalid value according to its data type.\r\n";

                Assert.AreEqual(msgExpected, msgActual, "Service return message.");
                Assert.AreEqual(false, log.IsSuccess, "IsSuccess");
                Assert.AreEqual(new DateTime(2000, 1, 1), log.LogDate, "LogDate");
            }
        }