-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolving image collection - adding tests
- Loading branch information
Showing
22 changed files
with
837 additions
and
29 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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ public enum Platform | |
UWP, | ||
macOS, | ||
Tizen, | ||
TVOS, | ||
Unsupported | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/Mobile.BuildTools.Tests/Fixtures/AndroidImageCollectionGeneratorFixture.cs
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,22 @@ | ||
using System.IO; | ||
using Mobile.BuildTools.Build; | ||
using Mobile.BuildTools.Generators.Images; | ||
using Xunit.Abstractions; | ||
|
||
namespace Mobile.BuildTools.Tests.Fixtures | ||
{ | ||
|
||
public class AndroidImageCollectionGeneratorFixture : ImageCollectionGeneratorFixture | ||
{ | ||
public AndroidImageCollectionGeneratorFixture(ITestOutputHelper testOutputHelper) | ||
: base(Path.Join(ImageDirectory, "MonoAndroid"), testOutputHelper) | ||
{ | ||
} | ||
|
||
internal override ImageCollectionGeneratorBase CreateGenerator(IBuildConfiguration config, params string[] searchFolders) => | ||
new AndroidImageCollectionGenerator(config) | ||
{ | ||
SearchFolders = searchFolders | ||
}; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/Mobile.BuildTools.Tests/Fixtures/AppleImageCollectionGeneratorFixture.cs
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,22 @@ | ||
using System.IO; | ||
using Mobile.BuildTools.Build; | ||
using Mobile.BuildTools.Generators.Images; | ||
using Xunit.Abstractions; | ||
|
||
namespace Mobile.BuildTools.Tests.Fixtures | ||
{ | ||
public class AppleImageCollectionGeneratorFixture : ImageCollectionGeneratorFixture | ||
{ | ||
public AppleImageCollectionGeneratorFixture(ITestOutputHelper testOutputHelper) | ||
: base(Path.Join(ImageDirectory, "Xamarin.iOS"), Path.Combine("Templates", "Apple"), testOutputHelper) | ||
{ | ||
PlatformOffset = 1; | ||
} | ||
|
||
internal override ImageCollectionGeneratorBase CreateGenerator(IBuildConfiguration config, params string[] searchFolders) => | ||
new AppleImageCollectionGenerator(config) | ||
{ | ||
SearchFolders = searchFolders | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,25 +1,81 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using Mobile.BuildTools.Tests.Mocks; | ||
using Xunit.Abstractions; | ||
|
||
namespace Mobile.BuildTools.Tests.Fixtures | ||
{ | ||
public class FixtureBase | ||
public abstract class FixtureBase | ||
{ | ||
protected ITestOutputHelper _testOutputHelper { get; } | ||
protected string ProjectDirectory { get; } | ||
|
||
public FixtureBase(ITestOutputHelper testOutputHelper) | ||
protected FixtureBase(ITestOutputHelper testOutputHelper) | ||
{ | ||
_testOutputHelper = testOutputHelper; | ||
} | ||
|
||
protected TestBuildConfiguration GetConfiguration() => | ||
new TestBuildConfiguration | ||
protected FixtureBase(string projectDirectory, ITestOutputHelper testOutputHelper) | ||
: this(testOutputHelper) | ||
{ | ||
ProjectDirectory = projectDirectory; | ||
} | ||
|
||
protected TestBuildConfiguration GetConfiguration() | ||
{ | ||
var stackTrace = new StackTrace(); | ||
var testOutput = Path.Combine("Tests", stackTrace.GetFrame(1).GetMethod().Name); | ||
if(Directory.Exists(testOutput)) | ||
{ | ||
Directory.Delete(testOutput, true); | ||
} | ||
|
||
Directory.CreateDirectory(testOutput); | ||
return new TestBuildConfiguration | ||
{ | ||
Logger = new XunitLog(_testOutputHelper), | ||
Platform = Tasks.Utils.Platform.Unsupported, | ||
IntermediateOutputPath = testOutput, | ||
ProjectDirectory = ProjectDirectory | ||
}; | ||
} | ||
|
||
protected static void DirectoryCopy(string sourceDirName, string destDirName) | ||
{ | ||
// Get the subdirectories for the specified directory. | ||
var dir = new DirectoryInfo(sourceDirName); | ||
|
||
if (!dir.Exists) | ||
{ | ||
throw new DirectoryNotFoundException( | ||
"Source directory does not exist or could not be found: " | ||
+ sourceDirName); | ||
} | ||
|
||
var dirs = dir.GetDirectories(); | ||
// If the destination directory doesn't exist, create it. | ||
if (!Directory.Exists(destDirName)) | ||
{ | ||
Directory.CreateDirectory(destDirName); | ||
} | ||
|
||
// Get the files in the directory and copy them to the new location. | ||
var files = dir.GetFiles(); | ||
foreach (var file in files) | ||
{ | ||
if (file.Name == ".DS_Store") | ||
continue; | ||
|
||
var temppath = Path.Combine(destDirName, file.Name); | ||
file.CopyTo(temppath, false); | ||
} | ||
|
||
// copy subdirectories, copy them and their contents to new location. | ||
foreach (var subdir in dirs) | ||
{ | ||
var temppath = Path.Combine(destDirName, subdir.Name); | ||
DirectoryCopy(subdir.FullName, temppath); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.