[TestClass] public class ValidSignClientTest { private ValidSignSettings _settings; private ISigningProviderAccount _account; private OssClient _validSignClient; private OssClient ValidSignClient => _validSignClient ??= new OssClient(_account.GetApiKey(), _settings.Url); private DocumentPackage createPackageThatHasAttachmentRequirement() { // Create a package to create a template var templateName = $"AttachmentRequirement Unittest ({DateTime.Now})"; var packageBuilder = PackageBuilder.NewPackageNamed(templateName) .DescribedAs("Template with AttachmentRequirement") .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings()); // Add a role with an attachment requirement var placeHolder = SignerBuilder.NewSignerPlaceholder(new Placeholder("Signer2")); var attachmentRequirement = new AttachmentRequirementBuilder("Attachment 1") .WithDescription("Please add attachment") .IsRequiredAttachment() .Build(); placeHolder.WithAttachmentRequirement(attachmentRequirement); packageBuilder.WithSigner(placeHolder); return packageBuilder.Build(); } [TestMethod] public void GetTemplate_WithAttachmentRequirement_HasData() { var templateId = string.Empty; try { // Arrange setSigningProvider(); var package = createPackageThatHasAttachmentRequirement(); // Act templateId = ValidSignClient.CreateTemplate(package).Id; // Assert var template = ValidSignClient.GetPackage(new PackageId(templateId)) ?? throw new Exception("Package not found"); Assert.IsTrue(template.Placeholders.SelectMany(x => x.Attachments).Any(), "It should have an attachment requirement"); } finally { if(!string.IsNullOrEmpty(templateId)) ValidSignClient.PackageService.DeletePackage(new PackageId(templateId)); _validSignClient = null; } } [TestMethod, ExpectedException(typeof(NullReferenceException))] public void GetTemplates_WithAttachmentRequirement_ThrowsNullReferenceException() { var templateId = string.Empty; // NuGetPackage Version 11.57 .. 11.59 try { // Arrange setSigningProvider(); var package = createPackageThatHasAttachmentRequirement(); templateId = ValidSignClient.CreateTemplate(package).Id; // Act var templates = ValidSignClient.PackageService.GetTemplates(new PageRequest(0), Visibility.ACCOUNT); } finally { if (!string.IsNullOrEmpty(templateId)) ValidSignClient.PackageService.DeletePackage(new PackageId(templateId)); _validSignClient = null; } } private void setSigningProvider() { // Set _settings & _account } }