File tree Expand file tree Collapse file tree 6 files changed +23
-16
lines changed Expand file tree Collapse file tree 6 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
## [ Unreleased]
5
5
6
6
7
+ ## [ 1.4.6] - 2023-06-07
8
+
9
+ ### Changed
10
+ - Do not throw for returning single record methods in MinecraftJar, instead return NULL
11
+
12
+
7
13
## [ 1.4.5] - 2023-06-04
8
14
9
15
### Fixed
Original file line number Diff line number Diff line change @@ -13,14 +13,15 @@ public class ProjectTests
13
13
public void GetProviderByProject_Success ( string providerName )
14
14
{
15
15
var provider = MinecraftJar . GetProvider ( providerName ) ;
16
+ Assert . That ( provider , Is . Not . Null ) ;
16
17
17
- foreach ( var project in provider . Projects )
18
+ foreach ( var project in provider ! . Projects )
18
19
{
19
20
var providerByProject = MinecraftJar . GetProvider ( project ) ;
20
21
Assert . That ( providerByProject , Is . SameAs ( provider ) ) ;
21
22
22
23
TestContext . Progress . WriteLine ( "{0}: Provider for project {1} is {2}" ,
23
- nameof ( GetProviderByProject_Success ) , providerByProject . Name , project . Name ) ;
24
+ nameof ( GetProviderByProject_Success ) , providerByProject ! . Name , project . Name ) ;
24
25
}
25
26
}
26
27
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public void GetProviderByName_Success()
48
48
[ TestCase ( "InvalidProviderName" ) , Order ( 5 ) ]
49
49
public void GetProviderByName_InvalidProvider ( string name )
50
50
{
51
- Assert . Throws < InvalidOperationException > ( ( ) => MinecraftJar . GetProvider ( name ) ) ;
51
+ Assert . That ( MinecraftJar . GetProvider ( name ) , Is . Null ) ;
52
52
TestContext . Progress . WriteLine ( "{0}: Provider name {1} invalid" , nameof ( GetProviderByName_InvalidProvider ) , name ) ;
53
53
}
54
54
}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ private static IEnumerable<string> Projects() =>
12
12
[ TestCaseSource ( nameof ( Projects ) ) , Order ( 1 ) ]
13
13
public void GetProjectsByName_Success ( string projectName )
14
14
{
15
- Assert . DoesNotThrow ( ( ) => MinecraftJar . GetProject ( projectName ) ) ;
15
+ Assert . That ( MinecraftJar . GetProject ( projectName ) , Is . Not . Null ) ;
16
16
TestContext . Progress . WriteLine ( "{0}: Project found by name {1}" ,
17
17
nameof ( GetProjectsByName_Success ) , projectName ) ;
18
18
}
Original file line number Diff line number Diff line change @@ -16,14 +16,14 @@ public interface IMinecraftJar
16
16
IEnumerable < IMinecraftProvider > GetProviders ( ProjectGroup projectGroup ) ;
17
17
18
18
/// <summary>
19
- /// Return a specific provider
19
+ /// Return a specific provider, null if not found
20
20
/// </summary>
21
- IMinecraftProvider GetProvider ( string providerName ) ;
21
+ IMinecraftProvider ? GetProvider ( string providerName ) ;
22
22
23
23
/// <summary>
24
- /// Return the provider for the provided Project
24
+ /// Return the provider for the provided Project, null if not found
25
25
/// </summary>
26
- IMinecraftProvider GetProvider ( IMinecraftProject project ) ;
26
+ IMinecraftProvider ? GetProvider ( IMinecraftProject project ) ;
27
27
28
28
/// <summary>
29
29
/// Return a list of all projects (e.g. Vanilla, Spigot, etc.)
@@ -36,7 +36,7 @@ public interface IMinecraftJar
36
36
IEnumerable < IMinecraftProject > GetProjects ( ProjectGroup projectGroup ) ;
37
37
38
38
/// <summary>
39
- /// Return project by it's name
39
+ /// Return project by it's name, null if not found
40
40
/// </summary>
41
- IMinecraftProject GetProject ( string projectName ) ;
41
+ IMinecraftProject ? GetProject ( string projectName ) ;
42
42
}
Original file line number Diff line number Diff line change @@ -42,18 +42,18 @@ from project in provider.Projects
42
42
select provider ;
43
43
}
44
44
45
- public IMinecraftProvider GetProvider ( string providerName )
45
+ public IMinecraftProvider ? GetProvider ( string providerName )
46
46
{
47
47
return ( from provider in GetProviders ( )
48
48
where provider . Name . Equals ( providerName )
49
- select provider ) . Single ( ) ;
49
+ select provider ) . SingleOrDefault ( ) ;
50
50
}
51
51
52
- public IMinecraftProvider GetProvider ( IMinecraftProject project )
52
+ public IMinecraftProvider ? GetProvider ( IMinecraftProject project )
53
53
{
54
54
return ( from provider in GetProviders ( )
55
55
where provider . Projects . Contains ( project )
56
- select provider ) . Single ( ) ;
56
+ select provider ) . SingleOrDefault ( ) ;
57
57
}
58
58
59
59
public IEnumerable < IMinecraftProject > GetProjects ( )
@@ -71,11 +71,11 @@ from project in provider.Projects
71
71
select project ;
72
72
}
73
73
74
- public IMinecraftProject GetProject ( string projectName )
74
+ public IMinecraftProject ? GetProject ( string projectName )
75
75
{
76
76
return ( from provider in GetProviders ( )
77
77
from project in provider . Projects
78
78
where project . Name . Equals ( projectName )
79
- select project ) . Single ( ) ;
79
+ select project ) . SingleOrDefault ( ) ;
80
80
}
81
81
}
You can’t perform that action at this time.
0 commit comments