mirror of
https://github.com/aphrody-labs/NuGet.Client.git
synced 2026-10-14 21:39:05 +00:00
Crated a new struct to parse the assets file using System.Text.Json instead of Newtonsoft. It will read the file without loading it completely in memory, reducing memory allocations. PRs associated with this: * Create class for reading Json files in chunks (#5530) * System.Text.Json Migration - Adding code to parse the PackageSpec using STJ (#5541) * System.Text.Json Migration - Adding code to parse the Project.Assets.Json file using STJ. (#5558) * Create class for reading Json files in chunks (#5530)
32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using Xunit;
|
|
|
|
namespace NuGet.ProjectModel.Test
|
|
{
|
|
public class StringExtensionTests
|
|
{
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
public void SplitInTwo_WithNullOrEmptyString_ReturnStringAndNull(string s)
|
|
{
|
|
var result = s.SplitInTwo('/');
|
|
Assert.Equal(s, result.firstPart);
|
|
Assert.Null(result.secondPart);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("part1/part2", "part1", "part2")]
|
|
[InlineData("part1/part2/NotPart3", "part1", "part2/NotPart3")]
|
|
public void SplitInTwo_WithSeperator_ReturnStringInTwoParts(string s, string expectedFirstPart, string expectedSecondPart)
|
|
{
|
|
var results = s.SplitInTwo('/');
|
|
Assert.Equal(expectedFirstPart, results.firstPart);
|
|
Assert.Equal(expectedSecondPart, results.secondPart);
|
|
}
|
|
}
|
|
}
|