Beispiel #1
0
        public void TestDispatchedTimeOutToDSNFail()
        {
            //
            // Sample data
            //
            MdnManager target = CreateManager();

            InitMdnRecords();
            CleanMessages(PickupFolder);

            //timespan and max records set
            var mdns = target.GetExpiredDispatched(TimeSpan.FromMinutes(10), 40);

            Assert.Equal(10, mdns.Count());

            MdnDispatchedTimeout dispatchedTimeout = new MdnDispatchedTimeout();

            //Execute unprocessed records over 11 minutes old.
            JobExecutionContext context = CreateDispatchedJobExecutionContext(11, 5);

            dispatchedTimeout.Execute(context);

            //Nothing was processed
            mdns = target.GetExpiredDispatched(TimeSpan.FromMinutes(10), 40);
            Assert.Equal(10, mdns.Count());

            var files = Directory.GetFiles(PickupFolder);

            Assert.Equal(0, files.Count());

            //Execute unprocessed records over 10 minutes old.
            context = CreateDispatchedJobExecutionContext(10, 5);
            dispatchedTimeout.Execute(context);

            //10 records left
            mdns = target.GetExpiredDispatched(TimeSpan.FromMinutes(10), 40);
            Assert.Equal(5, mdns.Count());

            files = Directory.GetFiles(PickupFolder);
            Assert.Equal(5, files.Count());

            //Do it again
            dispatchedTimeout.Execute(context);
            mdns = target.GetExpiredDispatched(TimeSpan.FromMinutes(10), 40);
            Assert.Equal(0, mdns.Count());

            files = Directory.GetFiles(PickupFolder);
            Assert.Equal(10, files.Count());

            foreach (var file in files)
            {
                Message loadedMessage = Message.Load(File.ReadAllText(file));
                Assert.True(loadedMessage.IsDSN());
                Assert.Equal("multipart/report", loadedMessage.ParsedContentType.MediaType);
                Assert.Equal("Rejected:To dispatch or not dispatch", loadedMessage.SubjectValue);
                var dsnActual = DSNParser.Parse(loadedMessage);
                Assert.Equal(DSNStandard.DSNAction.Failed, dsnActual.PerRecipient.First().Action);
                Assert.Equal("5.4.72", dsnActual.PerRecipient.First().Status);
            }
        }
Beispiel #2
0
        public void TestDispatchedTimeOutToDSNFail()
        {
            //
            // Sample data
            //
            MdnManager target = CreateManager();
            InitMdnRecords();
            CleanMessages(PickupFolder);

            //timespan and max records set
            var mdns = target.GetExpiredDispatched(TimeSpan.FromMinutes(10), 40);
            Assert.Equal(10, mdns.Count());

            MdnDispatchedTimeout dispatchedTimeout = new MdnDispatchedTimeout();

            //Execute unprocessed records over 11 minutes old.
            JobExecutionContext context = CreateDispatchedJobExecutionContext(11, 5);
            dispatchedTimeout.Execute(context);

            //Nothing was processed 
            mdns = target.GetExpiredDispatched(TimeSpan.FromMinutes(10), 40);
            Assert.Equal(10, mdns.Count());

            var files = Directory.GetFiles(PickupFolder);
            Assert.Equal(0, files.Count());

            //Execute unprocessed records over 10 minutes old.
            context = CreateDispatchedJobExecutionContext(10, 5);
            dispatchedTimeout.Execute(context);
            
            //10 records left
            mdns = target.GetExpiredDispatched(TimeSpan.FromMinutes(10), 40);
            Assert.Equal(5, mdns.Count());

            files = Directory.GetFiles(PickupFolder);
            Assert.Equal(5, files.Count());

            //Do it again
            dispatchedTimeout.Execute(context);
            mdns = target.GetExpiredDispatched(TimeSpan.FromMinutes(10), 40);
            Assert.Equal(0, mdns.Count());

            files = Directory.GetFiles(PickupFolder);
            Assert.Equal(10, files.Count());

            foreach (var file in files)
            {
                Message loadedMessage = Message.Load(File.ReadAllText(file));
                Assert.True(loadedMessage.IsDSN());
                Assert.Equal("multipart/report", loadedMessage.ParsedContentType.MediaType);
                Assert.Equal("Rejected:To dispatch or not dispatch", loadedMessage.SubjectValue);
                var dsnActual = DSNParser.Parse(loadedMessage);
                Assert.Equal(DSNStandard.DSNAction.Failed, dsnActual.PerRecipient.First().Action);
                Assert.Equal("5.4.72", dsnActual.PerRecipient.First().Status);
            }
        }