Skip to content

Conversation

@hiranya911
Copy link
Contributor

@hiranya911 hiranya911 commented Dec 6, 2018

go/dotnet-fcm

Implements the following parts of the API:

FireabseMessaging
    SendAsync()
Message
Notification
AndroidConfig
ApnsConfig
WebpushConfig

Rest of the API will be fleshed out in subsequent PRs.

Copy link

@bklimt bklimt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but with some minor feedback.

RestrictedPackageName = "com.google.firebase.testing",
},
};
var id = await FirebaseMessaging.DefaultInstance.SendAsync(message, dryRun: true);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't suppose there's any way to see that the message actually got all the parts it was supposed to?

It just seems kind of odd for an "integration test" to do a dryRun anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dryRun mode does validate for message content (both locally and at the server). The operation will fail if the message is invalid.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree with @bklimt this isn't great at the moment. Last time @alexames looked into testing this in the client SDKs end to end there wasn't really a way to do so without spinning up a XMPP server. If the REST request is formatted appropriately, I guess that's good enough for the mo'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do check the message content in our unit tests.


private void AssertJsonEquals(JObject expected, Message actual)
{
var json = NewtonsoftJsonSerializer.Instance.Serialize(actual.Validate());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use JsonConvert here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually needed for serialization (ok for deserialization). By default JsonConvert serializes null/zero values, which we don't want in the output.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use this btw:

string json = JsonConvert.SerializeObject(message, Formatting.None,
            new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore})```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @DenSmoke. NewtonsoftJsonSerializer from Google API client basically handles this. This prevents us from having to write the settings boilerplate in our code.

https://github.com/googleapis/google-api-dotnet-client/blob/bb7e9a2af7684ccd07e09ce0b52c2d00794795bb/Src/Support/Google.Apis.Core/Json/NewtonsoftJsonSerializer.cs#L141-L147

Copy link

@bklimt bklimt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM

@hiranya911 hiranya911 assigned hiranya911 and unassigned stewartmiles Feb 8, 2019
@hiranya911 hiranya911 merged commit 7aaf52f into master Feb 8, 2019
@hiranya911 hiranya911 deleted the hkj-fcm branch February 11, 2019 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants