diff --git a/src/chocolatey.tests/chocolatey.tests.csproj b/src/chocolatey.tests/chocolatey.tests.csproj index 85336ad736..c9ed8ef5fb 100644 --- a/src/chocolatey.tests/chocolatey.tests.csproj +++ b/src/chocolatey.tests/chocolatey.tests.csproj @@ -87,6 +87,7 @@ + @@ -127,9 +128,7 @@ chocolatey.console - - - + - + \ No newline at end of file diff --git a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs new file mode 100644 index 0000000000..d22e76223c --- /dev/null +++ b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs @@ -0,0 +1,61 @@ +// Copyright © 2017 - 2018 Chocolatey Software, Inc +// Copyright © 2011 - 2017 RealDimensions Software, LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the 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. + +namespace chocolatey.tests.infrastructure.app.nuget +{ + using System; + using System.Linq; + using chocolatey.infrastructure.app.configuration; + using chocolatey.infrastructure.app.nuget; + using Moq; + using NuGet; + using Should; + + public class NugetCommonSpecs + { + private class when_gets_remote_repository : TinySpec + { + private Action because; + private readonly Mock nugetLogger = new Mock(); + private readonly Mock packageDownloader = new Mock(); + private ChocolateyConfiguration configuration; + private IPackageRepository packageRepository; + + public override void Context() + { + configuration = new ChocolateyConfiguration(); + nugetLogger.ResetCalls(); + packageDownloader.ResetCalls(); + } + + public override void Because() + { + because = () => packageRepository = NugetCommon.GetRemoteRepository(configuration, nugetLogger.Object, packageDownloader.Object); + } + + [Fact] + public void should_create_repository_when_source_is_null() + { + Context(); + configuration.Sources = null; + + because(); + + ((AggregateRepository)packageRepository).Repositories.Count().ShouldEqual(0); + } + } + } +} diff --git a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs index 57639b2662..3f01352a5e 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs @@ -77,7 +77,7 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con }; } - IEnumerable sources = configuration.Sources.Split(new[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries); + IEnumerable sources = configuration.Sources.to_string().Split(new[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries); IList repositories = new List();