public void Good()
        {
            var cdn = new CdnLink(
                "ConnectionString",
                GetMockCdnApi(),
                new FtpBox("FtpHost", "FtpRoot", "FtpUser", "FtpPass"));

            Assert.AreEqual("ConnectionString", cdn.ConnectionString);
            Assert.AreEqual("FtpHost", cdn.FtpBox.Host);
            Assert.AreEqual("FtpRoot", cdn.FtpBox.Root);
            Assert.AreEqual("FtpUser", cdn.FtpBox.User);
            Assert.AreEqual("FtpPass", cdn.FtpBox.Pass);
        }
Ejemplo n.º 2
0
        public void Send()
        {
            var connectionString = Settings.GetConnectionString();

            var db = new CdnLinkDataContext(connectionString);
            db.ExecuteCommand(File.ReadAllText("Db\\testdata_send.sql"));
            var sendCount = db.CdnSends.Count();
            var link = new CdnLink(connectionString, GetMockCdnApi(), GetMockFtpBox(false));
            Assert.AreEqual(sendCount, link.Send());
            Assert.AreEqual(0, link.Send());

            foreach (var send in db.CdnSends)
            {
                Assert.AreEqual((int)CdnSend.SendStatus.Sent, send.Status);
            }
        }
Ejemplo n.º 3
0
        public void Send()
        {
            var connectionString = Settings.GetConnectionString();

            var db = new CdnLinkDataContext(connectionString);

            db.ExecuteCommand(File.ReadAllText("Db\\testdata_send.sql"));
            var sendCount = db.CdnSends.Count();
            var link      = new CdnLink(connectionString, GetMockCdnApi(), GetMockFtpBox(false));

            Assert.AreEqual(sendCount, link.Send());
            Assert.AreEqual(0, link.Send());

            foreach (var send in db.CdnSends)
            {
                Assert.AreEqual((int)CdnSend.SendStatus.Sent, send.Status);
            }
        }
Ejemplo n.º 4
0
        public void Receive()
        {
            var connectionString = Settings.GetConnectionString();
            var ftp = GetMockFtpBox(true);
            var fileNames = new List<string>(ftp.GetFileList());
            var cdn = new CdnLink(connectionString, new OpenApi("0", "0"), ftp);

            Assert.AreEqual(fileNames.Count, cdn.Receive());
            Assert.AreEqual(0, cdn.Receive());

            var db = new CdnLinkDataContext(connectionString);
            
            foreach (var filename in fileNames)
            {
                var ftpFile = db.CdnReceivedFtpFiles.Single(f => f.Filename.Contains(filename));
                Assert.IsNotNull(ftpFile);
                Assert.AreEqual(ftp.GetFileContents(filename), ftpFile.JsonMessage);

                var receive = ftpFile.CdnReceive;
                Assert.IsNotNull(receive);
                Assert.AreEqual((int)CdnReceive.ReceiveStatus.Queued, receive.Status);
                Assert.AreEqual(DateTime.Today, receive.FetchedDate.Date);

                var load = ftpFile.CdnReceivedLoads[0];
                Assert.IsNotNull(load);
                Assert.AreNotEqual(0, load.CdnId);

                var vehicles = load.CdnReceivedVehicles;
                Assert.IsNotNull(vehicles);
                Assert.Greater(vehicles.Count(), 0);
            }
        }
Ejemplo n.º 5
0
        public void Receive_NoFiles()
        {
            var connectionString = Settings.GetConnectionString();
            var ftp = GetMockFtpBox(false);
            var cdn = new CdnLink(connectionString, new OpenApi("0", "0"), ftp);

            Assert.AreEqual(0, cdn.Receive());
            Assert.AreEqual(0, cdn.Receive());
        }