Azure / azure-notificationhubs-dotnet

.NET SDK for Azure Notification Hubs
MIT License
73 stars 124 forks source link

NotificationHubConnectionStringBuilder has no ToString method #52

Closed sliekens closed 5 years ago

sliekens commented 5 years ago

I expected this to just work (based on my previous experiences with ConnectionStringBuilder types):

using Microsoft.Azure.NotificationHubs;
var builder = new NotificationHubConnectionStringBuilder("Endpoint=sb://my-namespace.servicebus.windows.net/")
{
    SharedAccessKeyName = "DefaultFullSharedAccessSignature",
    SharedAccessKey = "<therealsecret>"
};

var connectionString = builder.ToString();

Expected Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=<therealsecret>

Actual Microsoft.Azure.NotificationHubs.NotificationHubConnectionStringBuilder

brannon commented 5 years ago

@StevenLiekens thanks for the bug report. You're correct that this should just work. I'll add this to our backlog. We also accept pull requests 😉 .

sliekens commented 5 years ago

Hey @brannon, thanks for the reply. Given that I want to implement the ToString method and submit a PR, what tests do you expect me to write? I'm not sure how this class should handle garbage values like SharedAccessKeyName = null or "" or "🗑️". I'm also a little confused about the test project layout. Should the test go inside the DotNetCore.Tests project and then be linked from the DotNetFramework.Tests project?

marstr commented 5 years ago

I'm not @brannon, but my $0.02 on this:

I'm not sure how this class should handle garbage values like SharedAccessKeyName = null or "" or "🗑️".

I would not have the ToString be responsible for flagging garbage values. Rather, I would just go ahead and print out the results of those properties as stored in the properties. If we want/need validation in the future, it should live in the property setters.

Should the test go inside the DotNetCore.Tests project and then be linked from the DotNetFramework.Tests project?

I believe you have this right. Looking at the DotNetFramework.Tests project, the only items that are included in it are actually just linked in from the DotNetCore project. Following that pattern makes sense to me.

brannon commented 5 years ago

Thanks @marstr for chiming in. I agree that ToString should just format the property values as set in the properties. No need to validate the properties at this time.

The idea with the test projects is to provide a common set of tests that we can run for both .NET Core and .NET Framework targets.

marstr commented 5 years ago

Looks like this was completed by #91. I'm closing out this issue.