-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #1127 - "Catch GUIconfig.xml parsing error correctly" into master
* commit '1e33ebd': Configuration tests: tidy up tempdir at end of each test. Add tests for the LoadConfiguration method Catch XmlException too as it's the exception thrown by Mono Add more information in the error message of Configuration.LoadConfiguration Catch the correct type of exception in LoadConfiguration
- Loading branch information
Showing
4 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.IO; | ||
using CKAN; | ||
using NUnit.Framework; | ||
using Tests.Data; | ||
|
||
namespace Tests.GUI | ||
{ | ||
[TestFixture] | ||
public class ConfigurationTests | ||
{ | ||
string tempDir; | ||
|
||
[TestFixtureSetUp] | ||
public void Setup() | ||
{ | ||
tempDir = TestData.NewTempDir(); | ||
} | ||
|
||
[TestFixtureTearDown] | ||
public void TearDown() | ||
{ | ||
Directory.Delete(tempDir, true); | ||
} | ||
|
||
[Test] | ||
public void LoadConfiguration_MalformedXMLFile_ThrowsKraken() | ||
{ | ||
string tempFile = Path.Combine(tempDir, "invalid.xml"); | ||
|
||
using (var stream = new StreamWriter(tempFile)) | ||
{ | ||
stream.Write("This is not a valid XML file."); | ||
} | ||
|
||
Assert.Throws<Kraken>(() => Configuration.LoadConfiguration(tempFile)); | ||
} | ||
|
||
[Test] | ||
public void LoadConfiguration_CorrectConfigurationFile_Loaded() | ||
{ | ||
string tempFile = Path.Combine(tempDir, "valid.xml"); | ||
|
||
using (var stream = new StreamWriter(tempFile)) | ||
{ | ||
stream.Write(TestData.ConfigurationFile()); | ||
} | ||
|
||
var result = Configuration.LoadConfiguration(tempFile); | ||
|
||
Assert.IsNotNull(result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters