Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit e7df656

Browse files
committed
Move all URL strings into Urls.cs
1 parent 218e20a commit e7df656

File tree

6 files changed

+50
-39
lines changed

6 files changed

+50
-39
lines changed

test/GitHub.UI.UnitTests/GitHub.UI.UnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<Compile Include="Helpers\SharedDictionaryManagerBaseTests.cs" />
5959
<Compile Include="Helpers\SharedDictionaryManagerTests.cs" />
6060
<Compile Include="Helpers\LoadingResourceDictionaryTests.cs" />
61+
<Compile Include="Helpers\Urls.cs" />
6162
<Compile Include="Properties\AssemblyInfo.cs" />
6263
</ItemGroup>
6364
<ItemGroup>

test/GitHub.UI.UnitTests/Helpers/LoadingResourceDictionaryTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class LoadingResourceDictionaryTests
1010
public class TheSourceProperty
1111
{
1212
[Description("Load assembly using LoadFrom away from application base")]
13-
[TestCase("pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml")]
14-
[TestCase("pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml")]
13+
[TestCase(Urls.GitHub_UI_SharedDictionary_PackUrl)]
14+
[TestCase(Urls.GitHub_VisualStudio_UI_SharedDictionary_PackUrl)]
1515
[RequiresThread(System.Threading.ApartmentState.STA)]
1616
public void SetInLoadFromContext(string url)
1717
{
@@ -27,8 +27,8 @@ public void SetInLoadFromContext(string url)
2727
}
2828

2929
[Description("Load assembly using LoadFrom on application base")]
30-
[TestCase("pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml")]
31-
[TestCase("pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml")]
30+
[TestCase(Urls.GitHub_UI_SharedDictionary_PackUrl)]
31+
[TestCase(Urls.GitHub_VisualStudio_UI_SharedDictionary_PackUrl)]
3232
[RequiresThread(System.Threading.ApartmentState.STA)]
3333
public void SetInLoadContext(string url)
3434
{
@@ -56,8 +56,8 @@ internal int CountMergedDictionaries(string url)
5656
public class TheResourceDictionarySourceProperty
5757
{
5858
[Description("This shows why LoadingResourceDictionary is necessary")]
59-
[TestCase("pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml")]
60-
[TestCase("pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml")]
59+
[TestCase(Urls.GitHub_UI_SharedDictionary_PackUrl)]
60+
[TestCase(Urls.GitHub_VisualStudio_UI_SharedDictionary_PackUrl)]
6161
public void SetInLoadFromContext(string url)
6262
{
6363
var setup = new AppDomainSetup { ApplicationBase = "NOTHING_HERE" };
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
4-
xmlns:cache="clr-namespace:GitHub.UI.UnitTests"
5-
xmlns:ui="clr-namespace:GitHub.UI;assembly=GitHub.UI">
6-
7-
<ResourceDictionary.MergedDictionaries>
8-
<ResourceDictionary Source="pack://application:,,,/GitHub.UI;component/Assets/Styles.xaml" />
9-
</ResourceDictionary.MergedDictionaries>
10-
</ResourceDictionary>
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
</ResourceDictionary>

test/GitHub.UI.UnitTests/Helpers/SharedDictionaryManagerBaseTests.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class TheGetOrCreateResourceDictionaryMethod
1616
[Test]
1717
public void ReturnsResourceDictionary()
1818
{
19-
using (var factory = new SharedDictionaryManagerBase.CachingFactory())
19+
using (var factory = new SharedDictionaryManager.CachingFactory())
2020
{
21-
var uri = ResourceDictionaryUtilities.ToPackUri("pack://application:,,,/GitHub.UI.UnitTests;component/Helpers/SharedDictionary.xaml");
21+
var uri = ResourceDictionaryUtilities.ToPackUri(Urls.Test_SharedDictionary_PackUrl);
2222
var owner = new ResourceDictionary();
2323

2424
var resourceDictionary = factory.GetOrCreateResourceDictionary(owner, uri);
@@ -30,9 +30,9 @@ public void ReturnsResourceDictionary()
3030
[Test]
3131
public void ReturnsCachedResourceDictionary()
3232
{
33-
using (var factory = new SharedDictionaryManagerBase.CachingFactory())
33+
using (var factory = new SharedDictionaryManager.CachingFactory())
3434
{
35-
var uri = ResourceDictionaryUtilities.ToPackUri("pack://application:,,,/GitHub.UI.UnitTests;component/Helpers/SharedDictionary.xaml");
35+
var uri = ResourceDictionaryUtilities.ToPackUri(Urls.Test_SharedDictionary_PackUrl);
3636
var owner = new ResourceDictionary();
3737

3838
var resourceDictionary1 = factory.GetOrCreateResourceDictionary(owner, uri);
@@ -48,7 +48,7 @@ public class TheDisposeMethod
4848
[Test]
4949
public void CallsDisposeOnDisposable()
5050
{
51-
using (var factory = new SharedDictionaryManagerBase.CachingFactory())
51+
using (var factory = new SharedDictionaryManager.CachingFactory())
5252
{
5353
var disposable = Substitute.For<IDisposable>();
5454
factory.TryAddDisposable(disposable);
@@ -62,7 +62,7 @@ public void CallsDisposeOnDisposable()
6262
[Test]
6363
public void AddedTwice_DisposeCalledOnce()
6464
{
65-
using (var factory = new SharedDictionaryManagerBase.CachingFactory())
65+
using (var factory = new SharedDictionaryManager.CachingFactory())
6666
{
6767
var disposable = Substitute.For<IDisposable>();
6868
factory.TryAddDisposable(disposable);
@@ -81,12 +81,12 @@ public class TheGetCurrentDomainCachingFactoryMethod
8181
[Test]
8282
public void CalledTwice_DisposeNotCalled()
8383
{
84-
using (var factory = SharedDictionaryManagerBase.GetCurrentDomainCachingFactory())
84+
using (var factory = SharedDictionaryManager.GetCurrentDomainCachingFactory())
8585
{
8686
var disposable = Substitute.For<IDisposable>();
8787
factory.TryAddDisposable(disposable);
8888

89-
SharedDictionaryManagerBase.GetCurrentDomainCachingFactory();
89+
SharedDictionaryManager.GetCurrentDomainCachingFactory();
9090

9191
disposable.Received(0).Dispose();
9292
}
@@ -95,12 +95,12 @@ public void CalledTwice_DisposeNotCalled()
9595
[Test]
9696
public void InvokeMethodOnNewAssembly_DisposeCalled()
9797
{
98-
using (var factory = SharedDictionaryManagerBase.GetCurrentDomainCachingFactory())
98+
using (var factory = SharedDictionaryManager.GetCurrentDomainCachingFactory())
9999
{
100100
var disposable = Substitute.For<IDisposable>();
101101
factory.TryAddDisposable(disposable);
102102

103-
using (InvokeMethodOnNewAssembly(SharedDictionaryManagerBase.GetCurrentDomainCachingFactory))
103+
using (InvokeMethodOnNewAssembly(SharedDictionaryManager.GetCurrentDomainCachingFactory))
104104
{
105105
disposable.Received(1).Dispose();
106106
}
@@ -121,28 +121,30 @@ static IDisposable InvokeMethodOnNewAssembly<T>(Func<T> func)
121121

122122
public class TheFixDesignTimeUriMethod
123123
{
124-
[TestCase("pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml", "pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml")]
125-
[TestCase("file:///x:/solution/src/GitHub.VisualStudio.UI/SharedDictionary.xaml", "pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml")]
126-
[TestCase("file:///x:/solution/src/GitHub.VisualStudio.UI/Styles/GitHubComboBox.xaml", "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/GitHubComboBox.xaml")]
124+
[TestCase(Urls.GitHub_VisualStudio_UI_SharedDictionary_PackUrl, Urls.GitHub_VisualStudio_UI_SharedDictionary_PackUrl)]
125+
[TestCase(Urls.GitHub_VisualStudio_UI_SharedDictionary_FileUrl, Urls.GitHub_VisualStudio_UI_SharedDictionary_PackUrl)]
126+
127+
128+
[TestCase(Urls.GitHub_VisualStudio_UI_Styles_GitHubComboBox_FileUrl, Urls.GitHub_VisualStudio_UI_Styles_GitHubComboBox_PackUrl)]
127129
public void FixDesignTimeUri(string inUrl, string outUrl)
128130
{
129131
var inUri = ResourceDictionaryUtilities.ToPackUri(inUrl);
130132

131-
var outUri = SharedDictionaryManagerBase.FixDesignTimeUri(inUri);
133+
var outUri = SharedDictionaryManager.FixDesignTimeUri(inUri);
132134

133135
Assert.That(outUri.ToString(), Is.EqualTo(outUrl));
134136
}
135137
}
136138

137139
public class TheSourceProperty
138140
{
139-
[TestCase("pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml")]
141+
[TestCase(Urls.Test_SharedDictionary_PackUrl)]
140142
public void IsEqualToSet(string url)
141143
{
142-
using (SharedDictionaryManagerBase.GetCurrentDomainCachingFactory())
144+
using (SharedDictionaryManager.GetCurrentDomainCachingFactory())
143145
{
144146
var uri = ResourceDictionaryUtilities.ToPackUri(url);
145-
var target = new SharedDictionaryManagerBase();
147+
var target = new SharedDictionaryManager();
146148

147149
target.Source = uri;
148150

test/GitHub.UI.UnitTests/Helpers/SharedDictionaryManagerTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public partial class SharedDictionaryManagerTests
88
{
99
public class TheSourceProperty
1010
{
11-
[TestCase("pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml")]
12-
[TestCase("pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml")]
13-
[TestCase("file:///x:/Project/src/GitHub.UI/SharedDictionary.xaml", Description = "This is a design time URL")]
14-
[TestCase("file:///x:/Project/src/GitHub.VisualStudio.UI/SharedDictionary.xaml", Description = "This is a design time URL")]
11+
[TestCase(Urls.GitHub_UI_SharedDictionary_PackUrl)]
12+
[TestCase(Urls.GitHub_VisualStudio_UI_SharedDictionary_PackUrl)]
13+
[TestCase(Urls.GitHub_UI_SharedDictionary_FileUrl, Description = "This is a design time URL")]
14+
[TestCase(Urls.GitHub_VisualStudio_UI_SharedDictionary_FileUrl, Description = "This is a design time URL")]
1515
[RequiresThread(System.Threading.ApartmentState.STA)]
1616
public void SetSourceOnDifferentInstances_ExpectTheSameObjects(string url)
1717
{
@@ -28,8 +28,8 @@ public void SetSourceOnDifferentInstances_ExpectTheSameObjects(string url)
2828
}
2929

3030
// This is why we need `SharedDictionaryManager`.
31-
[TestCase("pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml")]
32-
[TestCase("pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml")]
31+
[TestCase(Urls.GitHub_UI_SharedDictionary_PackUrl)]
32+
[TestCase(Urls.GitHub_VisualStudio_UI_SharedDictionary_PackUrl)]
3333
[RequiresThread(System.Threading.ApartmentState.STA)]
3434
public void SetResourceDictionarySourceOnDifferentInstances_ExpectDifferentObjects(string url)
3535
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace GitHub.UI.Helpers.UnitTests
2+
{
3+
public class Urls
4+
{
5+
public const string Test_SharedDictionary_PackUrl = "pack://application:,,,/GitHub.UI.UnitTests;component/Helpers/SharedDictionary.xaml";
6+
7+
public const string GitHub_UI_SharedDictionary_PackUrl = "pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml";
8+
public const string GitHub_UI_SharedDictionary_FileUrl = "file:///x:/Project/src/GitHub.UI/SharedDictionary.xaml", Description = "This is a design time URL";
9+
10+
public const string GitHub_VisualStudio_UI_SharedDictionary_PackUrl = "pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml";
11+
public const string GitHub_VisualStudio_UI_SharedDictionary_FileUrl = "file:///x:/Project/src/GitHub.VisualStudio.UI/SharedDictionary.xaml";
12+
13+
public const string GitHub_VisualStudio_UI_Styles_GitHubComboBox_PackUrl = "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/GitHubComboBox.xaml";
14+
public const string GitHub_VisualStudio_UI_Styles_GitHubComboBox_FileUrl = "file:///x:/solution/src/GitHub.VisualStudio.UI/Styles/GitHubComboBox.xaml";
15+
}
16+
}

0 commit comments

Comments
 (0)