-
Notifications
You must be signed in to change notification settings - Fork 748
Expand file tree
/
Copy pathRepositoryTests.cs
More file actions
69 lines (54 loc) · 2.1 KB
/
RepositoryTests.cs
File metadata and controls
69 lines (54 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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 System;
using System.Collections.Generic;
using System.Linq;
using NuGet.Protocol.Core.Types;
using Xunit;
namespace NuGet.Protocol.Tests
{
public class RepositoryTests
{
[Fact]
public void Factory_Always_ReturnsSameInstance()
{
Repository.RepositoryFactory instance0 = Repository.Factory;
Repository.RepositoryFactory instance1 = Repository.Factory;
Assert.Same(instance0, instance1);
}
[Fact]
public void Provider_Always_ReturnsSameInstance()
{
Repository.ProviderFactory instance0 = Repository.Provider;
Repository.ProviderFactory instance1 = Repository.Provider;
Assert.Same(instance0, instance1);
}
[Fact]
public void Provider_WhenSettingNull_Throws()
{
var exception = Assert.Throws<ArgumentNullException>(() => Repository.Provider = null);
Assert.Equal("value", exception.ParamName);
}
[Fact]
public void Provider_WhenSetting_SetsFactory()
{
// It's important to test robustness that we use the same type as the default.
var newProviderFactory = new Repository.ProviderFactory();
Repository.Provider = newProviderFactory;
Assert.Same(newProviderFactory, Repository.Provider);
}
[Fact]
public void Provider_WhenGetting_ReturnsDefault()
{
Repository.ProviderFactory provider = Repository.Provider;
Assert.Equal(typeof(Repository.ProviderFactory).FullName, provider.GetType().FullName);
}
[Fact]
public void Provider_WithDefaultProvider_ReturnsDefaultResourceProviders()
{
IEnumerable<Lazy<INuGetResourceProvider>> resourceProviders = Repository.Provider.GetCoreV3();
int actualCount = resourceProviders.Count();
Assert.Equal(48, actualCount);
}
}
}