public void CreateReceiveLocationOneWay()
        {
            var dsl = new TestApplication.OneWayReceiveLocation();

            var visitor = BindingInfoBuilderVisitor.Create();
            var binding = visitor.CreateReceiveLocation(dsl);

            Assert.That(binding.Name, Is.EqualTo("OneWayReceiveLocation"));
            Assert.That(binding.Address, Is.EqualTo(@"c:\files\drops\*.xml"));
            Assert.That(binding.Description, Is.EqualTo("Some Useless One-Way Test Receive Location"));
            Assert.That(binding.Enable, Is.False);
            Assert.That(binding.EndDate, Is.EqualTo(dsl.Transport.Schedule.StopDate));
            Assert.That(binding.EndDateEnabled, Is.True);
            Assert.That(binding.FromTime, Is.EqualTo((DateTime)dsl.Transport.Schedule.ServiceWindow.StartTime));
            Assert.That(binding.ReceiveHandler.Name, Is.EqualTo("Receive Host Name"));
            Assert.That(binding.ReceivePipeline.Name, Is.EqualTo(typeof(PassThruReceive).FullName));
            Assert.That(binding.ReceivePipeline.FullyQualifiedName, Is.EqualTo(typeof(PassThruReceive).AssemblyQualifiedName));
            Assert.That(binding.ReceivePipeline.TrackingOption, Is.EqualTo(PipelineTrackingTypes.None));
            Assert.That(binding.ReceiveHandler.TransportType.Name, Is.EqualTo("Test Dummy"));
            Assert.That(binding.ReceivePipeline.Type, Is.EqualTo(PipelineRef.ReceivePipelineRef().Type));
            Assert.That(binding.ReceivePipelineData, Is.Not.Null.And.Not.Empty);
            Assert.That(binding.SendPipeline, Is.Null);
            Assert.That(binding.SendPipelineData, Is.Null);
            Assert.That(binding.ServiceWindowEnabled, Is.True);
            Assert.That(binding.StartDate, Is.EqualTo(dsl.Transport.Schedule.StartDate));
            Assert.That(binding.StartDateEnabled, Is.True);
            Assert.That(binding.ToTime, Is.EqualTo((DateTime)dsl.Transport.Schedule.ServiceWindow.StopTime));
        }
        public void CreateSendPortTwoWay()
        {
            var visitor = BindingInfoBuilderVisitor.Create();

            // initialize BindingInfoBuilderVisitor.ApplicationName
            visitor.VisitApplicationBinding(new TestApplication());
            var binding = visitor.CreateSendPort(new TestApplication.TwoWaySendPort());

            Assert.That(binding.ApplicationName, Is.EqualTo("TestApplication"));
            Assert.That(binding.Description, Is.EqualTo("Some Useless Two-Way Test Send Port"));
            Assert.That(binding.Filter, Is.Null);
            Assert.That(binding.IsDynamic, Is.False);
            Assert.That(binding.IsStatic, Is.True);
            Assert.That(binding.IsTwoWay, Is.True);
            Assert.That(binding.Name, Is.EqualTo("TwoWaySendPort"));
            Assert.That(binding.PrimaryTransport.FromTime, Is.EqualTo((DateTime)ServiceWindow.None.StartTime));
            Assert.That(binding.PrimaryTransport.Primary, Is.True);
            Assert.That(binding.PrimaryTransport.RetryCount, Is.EqualTo(RetryPolicy.Default.Count));
            Assert.That(binding.PrimaryTransport.RetryInterval, Is.EqualTo(RetryPolicy.Default.Interval.TotalMinutes));
            Assert.That(binding.PrimaryTransport.SendHandler.Name, Is.EqualTo("Send Host Name"));
            Assert.That(binding.PrimaryTransport.SendHandler.TransportType.Name, Is.EqualTo("Test Dummy"));
            Assert.That(binding.PrimaryTransport.ServiceWindowEnabled, Is.False);
            Assert.That(binding.PrimaryTransport.ToTime, Is.EqualTo((DateTime)ServiceWindow.None.StopTime));
            Assert.That(binding.ReceivePipeline.Name, Is.EqualTo(typeof(PassThruReceive).FullName));
            Assert.That(binding.ReceivePipeline.FullyQualifiedName, Is.EqualTo(typeof(PassThruReceive).AssemblyQualifiedName));
            Assert.That(binding.ReceivePipeline.TrackingOption, Is.EqualTo(PipelineTrackingTypes.None));
            Assert.That(binding.ReceivePipeline.Type, Is.EqualTo(PipelineRef.ReceivePipelineRef().Type));
            Assert.That(binding.ReceivePipelineData, Is.Not.Null.And.Not.Empty);
            Assert.That(binding.SecondaryTransport, Is.Null);
            Assert.That(binding.SendPipelineData, Is.Empty);
            Assert.That(binding.TransmitPipeline.Name, Is.EqualTo(typeof(PassThruTransmit).FullName));
            Assert.That(binding.TransmitPipeline.FullyQualifiedName, Is.EqualTo(typeof(PassThruTransmit).AssemblyQualifiedName));
            Assert.That(binding.TransmitPipeline.TrackingOption, Is.EqualTo(PipelineTrackingTypes.None));
            Assert.That(binding.TransmitPipeline.Type, Is.EqualTo(PipelineRef.TransmitPipelineRef().Type));
        }
        protected virtual PipelineRef CreateReceivePipelineRef(ReceivePipeline receivePipeline)
        {
            var rp = PipelineRef.ReceivePipelineRef();

            receivePipeline.Description.IfNotNullOrEmpty(d => rp.Description = d);
            rp.Name = ((ITypeDescriptor)receivePipeline).FullName;
            rp.FullyQualifiedName = ((ITypeDescriptor)receivePipeline).AssemblyQualifiedName;
            // TODO allow to change TackingOption
            rp.TrackingOption = PipelineTrackingTypes.None;
            return(rp);
        }
        public void CreateReceiveLocationTwoWay()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var visitor = new BindingInfoBuilder();
            var binding = visitor.CreateReceiveLocation(new TwoWayReceiveLocation());

            binding.Name.Should().Be(nameof(TwoWayReceiveLocation));
            binding.Enable.Should().BeFalse();
            binding.Address.Should().Be(@"c:\file\drops\*.xml");
            binding.Description.Should().Be("Some Useless Two-Way Test Receive Location");

            binding.TransportType.Should().BeEquivalentTo(new ProtocolType {
                Name = "Test Dummy"
            });
            binding.TransportTypeData.Should().Be("<CustomProps />");
            binding.ReceiveHandler.Name.Should().Be("Receive Host Name");
            binding.ReceiveHandler.TransportType.Name.Should().Be("Test Dummy");

            binding.ReceivePipeline.Name.Should().Be(typeof(PassThruReceive).FullName);
            binding.ReceivePipeline.FullyQualifiedName.Should().Be(typeof(PassThruReceive).AssemblyQualifiedName);
            binding.ReceivePipeline.TrackingOption.Should().Be(PipelineTrackingTypes.None);
            binding.ReceivePipeline.Type.Should().Be(PipelineRef.ReceivePipelineRef().Type);
            binding.ReceivePipelineData.Should().BeEmpty();

            binding.SendPipeline.Name.Should().Be(typeof(PassThruTransmit).FullName);
            binding.SendPipeline.FullyQualifiedName.Should().Be(typeof(PassThruTransmit).AssemblyQualifiedName);
            binding.SendPipeline.TrackingOption.Should().Be(PipelineTrackingTypes.None);
            binding.SendPipeline.Type.Should().Be(PipelineRef.TransmitPipelineRef().Type);
            binding.SendPipelineData.Should().NotBeNullOrEmpty();

            binding.ScheduleTimeZone.Should().BeNull();
            binding.ScheduleAutoAdjustToDaylightSaving.Should().BeFalse();
            binding.StartDate.Should().Be(Schedule.None.StartDate);
            binding.StartDateEnabled.Should().BeFalse();
            binding.EndDate.Should().Be(Schedule.None.StopDate);
            binding.EndDateEnabled.Should().BeFalse();

            binding.ServiceWindowEnabled.Should().BeFalse();
            binding.FromTime.Should().Be(ServiceWindow.None.StartTime);
            binding.ToTime.Should().Be(ServiceWindow.None.StopTime);

            binding.ScheduleRecurrenceType.Should().Be(RecurrenceType.None);
            binding.ScheduleRecurFrom.Should().Be(new DailyServiceWindow().From);
            binding.ScheduleRecurInterval.Should().Be(1);
            binding.ScheduleDaysOfWeek.Should().Be(BtsDayOfWeek.None);
            binding.ScheduleMonths.Should().Be(Month.None);
            binding.ScheduleMonthDays.Should().Be(MonthDay.None);
            binding.ScheduleLastDayOfMonth.Should().BeFalse();
            binding.ScheduleOrdinalDayOfWeek.Should().Be(BtsDayOfWeek.None);
            binding.ScheduleOrdinalType.Should().Be(OrdinalType.None);
            binding.ScheduleIsOrdinal.Should().BeFalse();
        }
        public void CreateSendPortTwoWay()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var visitor = new BindingInfoBuilder();

            // initialize BindingInfoBuilder.ApplicationName
            ((IApplicationBindingVisitor)visitor).VisitApplicationBinding(new TestApplication());
            var binding = visitor.CreateSendPort(new TwoWaySendPort());

            binding.ApplicationName.Should().Be("TestApplication");
            binding.Description.Should().Be("Some Useless Two-Way Test Send Port");
            binding.Filter.Should().BeNull();
            binding.IsDynamic.Should().BeFalse();
            binding.IsStatic.Should().BeTrue();
            binding.IsTwoWay.Should().BeTrue();
            binding.Name.Should().Be(nameof(TwoWaySendPort));
            binding.PrimaryTransport.FromTime.Should().Be(ServiceWindow.None.StartTime);
            binding.PrimaryTransport.Primary.Should().BeTrue();
            binding.PrimaryTransport.RetryCount.Should().Be(RetryPolicy.Default.Count);
            binding.PrimaryTransport.RetryInterval.Should().Be((int)RetryPolicy.Default.Interval.TotalMinutes);
            binding.PrimaryTransport.SendHandler.Name.Should().Be("Send Host Name");
            binding.PrimaryTransport.SendHandler.TransportType.Name.Should().Be("Test Dummy");
            binding.PrimaryTransport.ServiceWindowEnabled.Should().BeFalse();
            binding.PrimaryTransport.ToTime.Should().Be(ServiceWindow.None.StopTime);
            binding.ReceivePipeline.Name.Should().Be(typeof(PassThruReceive).FullName);
            binding.ReceivePipeline.FullyQualifiedName.Should().Be(typeof(PassThruReceive).AssemblyQualifiedName);
            binding.ReceivePipeline.TrackingOption.Should().Be(PipelineTrackingTypes.None);
            binding.ReceivePipeline.Type.Should().Be(PipelineRef.ReceivePipelineRef().Type);
            binding.ReceivePipelineData.Should().NotBeNullOrEmpty();
            binding.SecondaryTransport.Should().BeNull();
            binding.SendPipelineData.Should().BeEmpty();
            binding.TransmitPipeline.Name.Should().Be(typeof(PassThruTransmit).FullName);
            binding.TransmitPipeline.FullyQualifiedName.Should().Be(typeof(PassThruTransmit).AssemblyQualifiedName);
            binding.TransmitPipeline.TrackingOption.Should().Be(PipelineTrackingTypes.None);
            binding.TransmitPipeline.Type.Should().Be(PipelineRef.TransmitPipelineRef().Type);
        }