mdevilliers / Toxiproxy.Net

Toxiproxy.Net is a .Net client for Shopify's Toxiproxy. Toxiproxy is a proxy to test your system by simulating network failure.
MIT License
53 stars 10 forks source link

Fixing seralization to not include non set values #18

Closed DmytryEmery closed 6 years ago

DmytryEmery commented 6 years ago

Currently the JSON serialization of the toxic object will add in fields like Toxicity, Direction or Name even if they are 'null' or default values.

This means for example if you don't explicitly set Toxicity, you'll end up with 0.

However, there are defaults in the actual toxiproxy: https://github.com/Shopify/toxiproxy#toxic-fields

With this change the fields will not be included in the json created if they are null.

First test is a little fragile, since it depends on Toxiproxy's behavior e.g. Assert.Equal( "latency_downstream", toxic.Name );

mdevilliers commented 6 years ago

Thanks for the contribution!