-
Notifications
You must be signed in to change notification settings - Fork 354
Disable Debug Assertion for Parsing NPM Person objects #722
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4d01518
Move Npm::Person to use a factory instead of constructor.
mjbvz 6538704
Remove debug logger for invalid person parsing
mjbvz c2c0e17
Added npm link
mjbvz f6a9d19
Added a few unit tests for Person that pin the existing behavior and …
mjbvz f5f0cef
Added person unit test
mjbvz 2297771
Undo @ prefixed names from resharper extract
mjbvz 0f016c6
Cleanup test method name slightly
mjbvz 9455b6c
Rebasing person
mjbvz a35eb8d
Merge remote-tracking branch 'Microsoft/master' into npm-person-parse…
mjbvz 877f06e
Merge
mjbvz 573b75f
Removed extra regexp logic
mjbvz 7f613cc
Remove now unused import
mjbvz 74088a2
Added test categories to person tests
mjbvz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // | ||
| // Apache 2.0 License | ||
| // | ||
| // You may obtain a copy of the License at | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
| // implied. See the License for the specific language governing | ||
| // permissions and limitations under the License. | ||
| // | ||
| //*********************************************************// | ||
|
|
||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| using Microsoft.NodejsTools.Npm.SPI; | ||
|
|
||
| namespace NpmTests { | ||
| [TestClass] | ||
| public class PersonTests { | ||
| [TestMethod, TestCategory("NpmIntegration")] | ||
| public void ShouldReturnEmptyPersonForNullOrEmptyInput() { | ||
| var sources = new[] { null, "", " ", " " }; | ||
| foreach (var emptySource in sources) { | ||
| var person = Person.CreateFromJsonSource(null); | ||
| Assert.IsNotNull(person); | ||
| Assert.AreEqual("", person.Name); | ||
| Assert.IsNull(person.Email); | ||
| Assert.IsNull(person.Url); | ||
| } | ||
| } | ||
|
|
||
| [TestMethod, TestCategory("NpmIntegration")] | ||
| public void ShouldReturnNameForObjectWithNameOnly() { | ||
| var name = "J Scripter"; | ||
| var sources = new[] { | ||
| @"{{""name"": ""{0}""}}", | ||
| @"{{""name"":""{0}""}}", | ||
| @"{{""name"": ""{0}""}}", | ||
| @"{{ ""name"": ""{0}"" }}", | ||
| }; | ||
| foreach (var source in sources) { | ||
| var json = string.Format(source, name); | ||
| var person = Person.CreateFromJsonSource(json); | ||
| Assert.IsNotNull(person); | ||
| Assert.AreEqual(name, person.Name); | ||
| Assert.IsNull(person.Email); | ||
| Assert.IsNull(person.Url); | ||
| } | ||
| } | ||
|
|
||
| [TestMethod, TestCategory("NpmIntegration")] | ||
| public void ShouldSetNameEmailAndUrlForObjectWithTheseProperties() { | ||
| var name = "J Scripter"; | ||
| var email = "j@contoso.com"; | ||
| var url = "http://contoso.com"; | ||
|
|
||
| var sources = new[] { | ||
| @"{{""name"": ""{0}"", ""email"": ""{1}"", ""url"": ""{2}""}}", | ||
| @"{{""url"": ""{2}"", ""email"": ""{1}"", ""name"": ""{0}""}}", | ||
| // Ignore other properties | ||
| @"{{""handle"": ""@code"", ""url"": ""{2}"", ""email"": ""{1}"", ""office"": ""1337"", ""name"": ""{0}""}}", | ||
| }; | ||
|
|
||
| foreach (var source in sources) { | ||
| var json = string.Format(source, name, email, url); | ||
| var person = Person.CreateFromJsonSource(json); | ||
| Assert.IsNotNull(person); | ||
| Assert.AreEqual(name, person.Name); | ||
| Assert.AreEqual(email, person.Email); | ||
| Assert.AreEqual(url, person.Url); | ||
| } | ||
| } | ||
|
|
||
| [TestMethod, TestCategory("NpmIntegration")] | ||
| public void ShouldReturnInputAsNameIfInputIsObject() { | ||
| var name = "J Scripter"; | ||
| var person = Person.CreateFromJsonSource(name); | ||
| Assert.IsNotNull(person); | ||
| Assert.AreEqual(name, person.Name); | ||
| Assert.IsNull(person.Email); | ||
| Assert.IsNull(person.Url); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
PersonObjectRegexandStringPersonRegexwould be clearerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just removed
StringPersonRegexsince it was not really being used