From ed709b1cbc3430d14a5126a5d96a34e524da4001 Mon Sep 17 00:00:00 2001 From: Klaus Fischer <klaus.fischer@eloware.com> Date: Thu, 12 Jan 2023 12:55:32 +0100 Subject: [PATCH] Resolved warnings, removed InputStreams for Submissions from public interface --- ConsoleAppExample/SenderDemo.cs | 9 +++++++++ ConsoleAppExample/SubscriberDemo.cs | 4 ++++ E2ETest/StraightForwardTest.cs | 8 ++++---- FitConnect/SubmissionBuilder.cs | 10 +++++++--- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ConsoleAppExample/SenderDemo.cs b/ConsoleAppExample/SenderDemo.cs index 960f76bb..0dcb9f51 100644 --- a/ConsoleAppExample/SenderDemo.cs +++ b/ConsoleAppExample/SenderDemo.cs @@ -13,6 +13,10 @@ public static class SenderDemo { var destinationId = config["FitConnect:Sender:DestinationId"]; var leikaKey = config["FitConnect:Sender:LeikaKey"]; + if (clientId == null || clientSecret == null || destinationId == null || leikaKey == null) { + logger.LogError("Missing configuration values"); + return; + } OutputHelper.PrintSender(); @@ -34,6 +38,11 @@ public static class SenderDemo { var destinationId = config["FitConnect:Sender:DestinationId"]; var leikaKey = config["FitConnect:Sender:LeikaKey"]; + if (clientId == null || clientSecret == null || destinationId == null || leikaKey == null) { + logger.LogError("Missing configuration values"); + return; + } + var encryption = new FitEncryption("", "", null); Dictionary<string, string>? encryptedAttachments = null; diff --git a/ConsoleAppExample/SubscriberDemo.cs b/ConsoleAppExample/SubscriberDemo.cs index 54ab8dd5..d69b4d47 100644 --- a/ConsoleAppExample/SubscriberDemo.cs +++ b/ConsoleAppExample/SubscriberDemo.cs @@ -11,6 +11,10 @@ public static class SubscriberDemo { var privateKeyDecryption = config["FitConnect:Subscriber:PrivateKeyDecryption"]; var privateKeySigning = config["FitConnect:Subscriber:PrivateKeySigning"]; + if (clientId == null || clientSecret == null || privateKeyDecryption == null || privateKeySigning == null) { + logger.LogError("Missing configuration values"); + return; + } OutputHelper.PrintSubscriber(); diff --git a/E2ETest/StraightForwardTest.cs b/E2ETest/StraightForwardTest.cs index 47510800..ce839a47 100644 --- a/E2ETest/StraightForwardTest.cs +++ b/E2ETest/StraightForwardTest.cs @@ -21,9 +21,9 @@ public class StraightForwardTest : EndToEndTestBase { .WithAttachments(new Attachment("Test.pdf", "Attachment #1"), new Attachment("Test.pdf", "Attachment #2")) .WithAttachments(new Attachment("Test.pdf", "Attachment #3")) - .WithAttachments("Test.pdf", "Attachment #4 - StreamReader", - System.Net.Mime.MediaTypeNames.Application.Pdf, - new FileStream("Test.pdf", FileMode.Open, FileAccess.Read)) + // .WithAttachments("Test.pdf", "Attachment #4 - StreamReader", + // System.Net.Mime.MediaTypeNames.Application.Pdf, + // new FileStream("Test.pdf", FileMode.Open, FileAccess.Read)) .Build(); var submission = Sender.SendAsync(outgoing).Result; @@ -90,7 +90,7 @@ public class StraightForwardTest : EndToEndTestBase { attachments.TrueForAll(a => a.Filename == "Test.pdf"); attachments.TrueForAll(a => a.Description?.StartsWith("Attachment #") ?? false).Should() .BeTrue(); - attachments.Count.Should().Be(4); + attachments.Count.Should().Be(3); var size = File.ReadAllBytes("Test.pdf").Length; attachments.ForEach(a => a.Content!.Length.Should().Be(size)); subscriberWithSubmission.AcceptSubmissionAsync().Wait(); diff --git a/FitConnect/SubmissionBuilder.cs b/FitConnect/SubmissionBuilder.cs index 688ec277..ca0d6b97 100644 --- a/FitConnect/SubmissionBuilder.cs +++ b/FitConnect/SubmissionBuilder.cs @@ -19,7 +19,7 @@ public class SubmissionBuilder : ISubmissionWithDestination, return WithAttachments(attachments.ToArray()); } - public ISubmissionWithData WithAttachments(string fileName, string description, string mimeType, + private ISubmissionWithData WithAttachments(string fileName, string description, string mimeType, FileStream fileStream) { byte[]? buffer; using (fileStream) { @@ -108,8 +108,12 @@ public interface ISubmissionWithData { ISubmissionWithData WithAttachments(params Attachment[] attachments); ISubmissionWithData WithAttachments(List<Attachment> attachments); - ISubmissionWithData WithAttachments(string fileName, string description, string mimeType, - FileStream content); + /// <summary> + /// For future use + /// </summary> + /// <returns></returns> + // ISubmissionWithData WithAttachments(string fileName, string description, string mimeType, + // FileStream content); SendableSubmission Build(); -- GitLab