Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting Multiple TestProperty with the same key value. #328

Merged
merged 4 commits into from
Jan 10, 2017

Conversation

navin22
Copy link
Member

@navin22 navin22 commented Jan 9, 2017

  • Changed the way of deserialization using custom TraitObject.
  • Added UnitTests for the same.

- Changed the way of deserialization using custom TraitObject.
- Added UnitTests for the same.
@navin22
Copy link
Member Author

navin22 commented Jan 9, 2017

image
Above are the numbers I am seeing with the change. Numbers are taken with sample data with just 2 test properties and for ConvertFrom function alone. Times are in milliseconds.

// Converting Json data to array of KeyValuePairs with duplicate keys.
var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<TraitObject>));

var listOfTratiObjects = serializer.ReadObject(stream) as List<TraitObject>;
Copy link
Contributor

Choose a reason for hiding this comment

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

s/listOfTratiObjects/listOfTraitObjects

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved it.

var listOfTratiObjects = serializer.ReadObject(stream) as List<TraitObject>;
listOfTratiObjects.ForEach(o=>listOfKvps.Add(new KeyValuePair<string, string>(o.Key, o.Value)));

return listOfKvps?.ToArray();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is null check required for listOfKvps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed.

var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<TraitObject>));

var listOfTratiObjects = serializer.ReadObject(stream) as List<TraitObject>;
listOfTratiObjects.ForEach(o=>listOfKvps.Add(new KeyValuePair<string, string>(o.Key, o.Value)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra allocation and insertion into listOfKvps may not be required. Is something like below possible?

listOfTratiObjects.Select(t => new KeyValuePair<string, string>(t.Key, t.Value)).ToArray()

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes possible. Changed it.

Copy link
Contributor

@codito codito left a comment

Choose a reason for hiding this comment

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

Approach looks fine. Request few changes.

@navin22
Copy link
Member Author

navin22 commented Jan 10, 2017

#239 issue is resolved by this PR.

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.

2 participants