public void DestinationFolderIsRequired()
        {
            var ofa = new FileAdapter.Outbound(a => { });

            Assert.That(
                () => ((ISupportValidation)ofa).Validate(),
                Throws.TypeOf <BindingException>().With.Message.EqualTo("Outbound file adapter has no destination folder."));
        }
        public void DestinationFolderIsRequired()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var ofa = new FileAdapter.Outbound(_ => { });

            Invoking(() => ((ISupportValidation)ofa).Validate())
            .Should().Throw <BindingException>()
            .WithMessage("Outbound file adapter has no destination folder.");
        }
        public void UseTempFileOnWriteAndAppendFileAreNotCompatible()
        {
            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder = @"\\server";
                a.Mode = FileAdapter.CopyMode.Append;
                a.UseTempFileOnWrite = false;
            });

            Assert.That(() => ((ISupportValidation)ofa).Validate(), Throws.Nothing);
        }
        public void CredentialsAreCompatibleWithNetworkFolder()
        {
            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder           = @"\\server\folder";
                a.NetworkCredentials.UserName = "******";
                a.NetworkCredentials.Password = "******";
            });

            Assert.That(() => ((ISupportValidation)ofa).Validate(), Throws.Nothing);
        }
        public void FileNameIsRequired()
        {
            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder = @"\\server";
                a.FileName          = string.Empty;
            });

            Assert.That(
                () => ((ISupportValidation)ofa).Validate(),
                Throws.TypeOf <BindingException>().With.Message.EqualTo("Outbound file adapter has no destination file name."));
        }
        public void FileNameIsRequired()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder = @"\\server";
                a.FileName          = string.Empty;
            });

            Invoking(() => ((ISupportValidation)ofa).Validate())
            .Should().Throw <BindingException>()
            .WithMessage("Outbound file adapter has no destination file name.");
        }
        public void CredentialsAreCompatibleWithNetworkFolder()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder           = @"\\server\folder";
                a.NetworkCredentials.UserName = "******";
                a.NetworkCredentials.Password = "******";
            });

            Invoking(() => ((ISupportValidation)ofa).Validate())
            .Should().NotThrow();
        }
        public void UseTempFileOnWriteAndCreateNewFileAreCompatible()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder = @"\\server";
                a.Mode = FileAdapter.CopyMode.CreateNew;
                a.UseTempFileOnWrite = true;
            });

            Invoking(() => ((ISupportValidation)ofa).Validate())
            .Should().NotThrow();
        }
        public void CredentialsAreNotCompatibleWithLocalFolder()
        {
            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder           = @"c:\files\drops";
                a.NetworkCredentials.UserName = "******";
                a.NetworkCredentials.Password = "******";
            });

            Assert.That(
                () => ((ISupportValidation)ofa).Validate(),
                Throws.TypeOf <BindingException>()
                .With.Message.EqualTo("Alternate credentials to access the file folder cannot be supplied while accessing local drive or a mapped network drive."));
        }
        public void UseTempFileOnWriteAndOverwriteFileAreNotCompatible()
        {
            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder = @"\\server";
                a.Mode = FileAdapter.CopyMode.Overwrite;
                a.UseTempFileOnWrite = true;
            });

            Assert.That(
                () => ((ISupportValidation)ofa).Validate(),
                Throws.TypeOf <BindingException>()
                .With.Message.EqualTo("Outbound file adapter cannot use a temporary file when it is meant to append or overwrite an existing file."));
        }
        public void SerializeToXml()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var ofa = new FileAdapter.Outbound(a => { a.DestinationFolder = @"c:\file\drops"; });
            var xml = ofa.GetAdapterBindingInfoSerializer().Serialize();

            xml.Should().Be(
                "<CustomProps>" +
                "<AllowCacheOnWrite vt=\"11\">0</AllowCacheOnWrite>" +
                "<CopyMode vt=\"19\">1</CopyMode>" +
                "<FileName vt=\"8\">%MessageID%.xml</FileName>" +
                "<UseTempFileOnWrite vt=\"11\">-1</UseTempFileOnWrite>" +
                "</CustomProps>");
        }
        public void CredentialsAreNotCompatibleWithLocalFolder()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder           = @"c:\file\drops";
                a.NetworkCredentials.UserName = "******";
                a.NetworkCredentials.Password = "******";
            });

            Invoking(() => ((ISupportValidation)ofa).Validate())
            .Should().Throw <BindingException>()
            .WithMessage("Alternate credentials to access the file folder cannot be supplied while accessing local drive or a mapped network drive.");
        }
        public void UseTempFileOnWriteAndOverwriteFileAreNotCompatible()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var ofa = new FileAdapter.Outbound(
                a => {
                a.DestinationFolder = @"\\server";
                a.Mode = FileAdapter.CopyMode.Overwrite;
                a.UseTempFileOnWrite = true;
            });

            Invoking(() => ((ISupportValidation)ofa).Validate())
            .Should().Throw <BindingException>()
            .WithMessage("Outbound file adapter cannot use a temporary file when it is meant to append or overwrite an existing file.");
        }
        public void SerializeToXml()
        {
            var ofa = new FileAdapter.Outbound(a => { a.DestinationFolder = @"c:\files\drops"; });
            var xml = ((IAdapterBindingSerializerFactory)ofa).GetAdapterBindingSerializer().Serialize();

            Assert.That(
                xml,
                Is.EqualTo(
                    "<CustomProps>" +
                    "<AllowCacheOnWrite vt=\"11\">0</AllowCacheOnWrite>" +
                    "<CopyMode vt=\"19\">1</CopyMode>" +
                    "<FileName vt=\"8\">%MessageID%.xml</FileName>" +
                    "<UseTempFileOnWrite vt=\"11\">-1</UseTempFileOnWrite>" +
                    "</CustomProps>"));
        }