-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kirill Krylo
committed
Sep 13, 2024
1 parent
932ecaf
commit 83b8a3e
Showing
29 changed files
with
476 additions
and
89 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
86 changes: 31 additions & 55 deletions
86
clio.tests/Command/ApplicationCommand/SetApplicationIconCommand.Tests.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 |
---|---|---|
@@ -1,72 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Abstractions.TestingHelpers; | ||
using System.Json; | ||
using Autofac; | ||
using Clio.Command.ApplicationCommand; | ||
using Clio.ComposableApplication; | ||
using FluentAssertions; | ||
using ICSharpCode.SharpZipLib.Zip; | ||
using NSubstitute; | ||
using NUnit.Framework; | ||
|
||
namespace Clio.Tests.Command.ApplicationCommand | ||
namespace Clio.Tests.Command.ApplicationCommand; | ||
|
||
internal class SetApplicationIconCommandTestCase : BaseCommandTests<SetApplicationVersionOption> | ||
{ | ||
|
||
internal class SetApplicationIconCommandTestCase : BaseCommandTests<SetApplicationVersionOption> | ||
{ | ||
private static string mockPackageFolderPath = Path.Combine("C:", "MockPackageFolder"); | ||
private static string mockPackageAppDescriptorPath = Path.Combine(mockPackageFolderPath, "Files", "app-descriptor.json"); | ||
private static string mockWorspacePath = Path.Combine("C:", "MockWorkspaceFolder"); | ||
private static string mockWorkspaceAppPackageFolderPath = Path.Combine(mockWorspacePath, "packages", "IFrameSample"); | ||
private static string mockWorkspaceAppDescriptorPath = Path.Combine(mockWorkspaceAppPackageFolderPath, "Files", "app-descriptor.json"); | ||
#region Fields: Private | ||
|
||
private static readonly string MockWorkspacePath = Path.Combine("C:", "MockWorkspaceFolder"); | ||
|
||
private static MockFileSystem CreateFs(string filePath, string packagePath) { | ||
string originClioSourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); | ||
string appDescriptorExamplesDescriptorPath = Path.Combine(originClioSourcePath, "Examples", "AppDescriptors", filePath); | ||
string mockAppDescriptorFilePath = Path.Combine(packagePath, "Files", "app-descriptor.json"); | ||
return new MockFileSystem(new Dictionary<string, MockFileData> { | ||
{ | ||
mockAppDescriptorFilePath, | ||
new MockFileData(File.ReadAllText(appDescriptorExamplesDescriptorPath)) | ||
} | ||
}); | ||
} | ||
private static readonly string MockWorkspaceAppPackageFolderPath | ||
= Path.Combine(MockWorkspacePath, "packages", "IFrameSample"); | ||
|
||
private static MockFileSystem CreateFs(Dictionary<string, string> appDescriptors) { | ||
string originClioSourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); | ||
MockFileSystem mockFileSystem = new MockFileSystem(); | ||
foreach (var appDescriptor in appDescriptors) { | ||
string appDescriptorExamplesDescriptorPath = Path.Combine(originClioSourcePath, "Examples", "AppDescriptors", appDescriptor.Value); | ||
string mockAppDescriptorJsonPath = Path.Combine(mockWorspacePath, "packages", appDescriptor.Key, "Files", "app-descriptor.json"); | ||
mockFileSystem.AddFile(mockAppDescriptorJsonPath, new MockFileData(File.ReadAllText(appDescriptorExamplesDescriptorPath))); | ||
} | ||
return mockFileSystem; | ||
} | ||
private IComposableApplicationManager _composableApplicationManager; | ||
|
||
private MockFileSystem _fileSystem; | ||
private IComposableApplicationManager composableApplicationManager; | ||
#endregion | ||
|
||
protected override void AdditionalRegistrations(ContainerBuilder containerBuilder) { | ||
composableApplicationManager = Substitute.For<IComposableApplicationManager>(); | ||
containerBuilder.RegisterInstance(composableApplicationManager); | ||
base.AdditionalRegistrations(containerBuilder); | ||
} | ||
#region Methods: Protected | ||
|
||
[Test] | ||
public void SetApplicationIconCommand_CallsComposableAppmanager() { | ||
string iconPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", "icon.svg"); | ||
string appName = "ExampleAppName"; | ||
var command = Container.Resolve<SetApplicationIconCommand>(); | ||
command.Execute(new SetApplicationIconOption { | ||
IconPath = iconPath, | ||
WorspaceFolderPath = mockWorspacePath, | ||
PackageFolderPath = mockWorkspaceAppPackageFolderPath, | ||
AppName = appName | ||
}); | ||
composableApplicationManager.Received(1).SetIcon(mockWorkspaceAppPackageFolderPath, iconPath, appName); | ||
} | ||
protected override void AdditionalRegistrations(ContainerBuilder containerBuilder){ | ||
_composableApplicationManager = Substitute.For<IComposableApplicationManager>(); | ||
containerBuilder.RegisterInstance(_composableApplicationManager); | ||
base.AdditionalRegistrations(containerBuilder); | ||
} | ||
|
||
#endregion | ||
|
||
[Test] | ||
public void SetApplicationIconCommand_CallsComposableAppmanager(){ | ||
string iconPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", "icon.svg"); | ||
string appName = "ExampleAppName"; | ||
SetApplicationIconCommand command = Container.Resolve<SetApplicationIconCommand>(); | ||
command.Execute(new SetApplicationIconOption { | ||
IconPath = iconPath, | ||
PackageFolderPath = MockWorkspaceAppPackageFolderPath, | ||
AppName = appName | ||
}); | ||
_composableApplicationManager.Received(1).SetIcon(MockWorkspaceAppPackageFolderPath, iconPath, appName); | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.