-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathDriverUpdaterFactoryTests.cs
More file actions
137 lines (118 loc) · 4 KB
/
Copy pathDriverUpdaterFactoryTests.cs
File metadata and controls
137 lines (118 loc) · 4 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using GeneralUpdate.Drivelution.Core;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
namespace DrivelutionTest.Core;
/// <summary>
/// Tests for DrivelutionFactory class.
/// Validates platform detection, factory creation, and platform-specific implementations.
/// </summary>
public class DrivelutionFactoryTests
{
/// <summary>
/// Tests that Create method returns a non-null instance.
/// </summary>
[Fact]
public void Create_WithoutParameters_ReturnsNonNullInstance()
{
// Arrange & Act
var updater = DrivelutionFactory.Create();
// Assert
Assert.NotNull(updater);
Assert.IsAssignableFrom<IGeneralDrivelution>(updater);
}
/// <summary>
/// Tests that Create method accepts custom options.
/// </summary>
[Fact]
public void Create_WithCustomOptions_ReturnsInstance()
{
// Arrange
var options = new DrivelutionOptions
{
DefaultBackupPath = "./backups"
};
// Act
var updater = DrivelutionFactory.Create(options);
// Assert
Assert.NotNull(updater);
}
/// <summary>
/// Tests that GetCurrentPlatform returns a valid platform name.
/// </summary>
[Fact]
public void GetCurrentPlatform_ReturnsValidPlatformName()
{
// Act
var platform = DrivelutionFactory.GetCurrentPlatform();
// Assert
Assert.NotNull(platform);
Assert.Contains(platform, new[] { "Windows", "Linux", "MacOS", "Unknown" });
}
/// <summary>
/// Tests that IsPlatformSupported returns a boolean value.
/// </summary>
[Fact]
public void IsPlatformSupported_ReturnsBooleanValue()
{
// Act
var isSupported = DrivelutionFactory.IsPlatformSupported();
// Assert
// Windows and Linux should be supported
Assert.True(isSupported || DrivelutionFactory.GetCurrentPlatform() == "MacOS" || DrivelutionFactory.GetCurrentPlatform() == "Unknown");
}
/// <summary>
/// Tests that CreateValidator returns a non-null instance.
/// </summary>
[Fact]
public void CreateValidator_WithoutParameters_ReturnsNonNullInstance()
{
// Skip on MacOS and Unknown platforms
var platform = DrivelutionFactory.GetCurrentPlatform();
if (platform == "MacOS" || platform == "Unknown")
{
return;
}
// Act
var validator = DrivelutionFactory.CreateValidator();
// Assert
Assert.NotNull(validator);
Assert.IsAssignableFrom<IDriverValidator>(validator);
}
/// <summary>
/// Tests that CreateBackup returns a non-null instance.
/// </summary>
[Fact]
public void CreateBackup_WithoutParameters_ReturnsNonNullInstance()
{
// Skip on MacOS and Unknown platforms
var platform = DrivelutionFactory.GetCurrentPlatform();
if (platform == "MacOS" || platform == "Unknown")
{
return;
}
// Act
var backup = DrivelutionFactory.CreateBackup();
// Assert
Assert.NotNull(backup);
Assert.IsAssignableFrom<IDriverBackup>(backup);
}
/// <summary>
/// Tests that Create throws PlatformNotSupportedException on unsupported platforms.
/// This test documents expected behavior but cannot be easily tested on supported platforms.
/// </summary>
[Fact]
public void Create_OnSupportedPlatform_DoesNotThrow()
{
// Skip on MacOS as it's not yet implemented
var platform = DrivelutionFactory.GetCurrentPlatform();
if (platform == "MacOS")
{
// MacOS should throw PlatformNotSupportedException
Assert.Throws<PlatformNotSupportedException>(() => DrivelutionFactory.Create());
return;
}
// Act & Assert - should not throw on Windows/Linux
var exception = Record.Exception(() => DrivelutionFactory.Create());
Assert.Null(exception);
}
}