Skip to content

Commit

Permalink
Added test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Osyatnik committed Mar 11, 2016
1 parent 2875ff7 commit 3b1a7c6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ internal PublishPackageViewModel()

private void BeginInvoke(Action action)
{
if (dynamoViewModel != null)
// dynamoViewModel.UIDispatcher can be null in unit tests.
if (dynamoViewModel != null && dynamoViewModel.UIDispatcher != null)
dynamoViewModel.UIDispatcher.BeginInvoke(action);
}

Expand Down Expand Up @@ -606,7 +607,7 @@ public static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoVie

switch (result)
{
case AssemblyLoadingState.Succes:
case AssemblyLoadingState.Success:
{
var isNodeLibrary = nodeLibraryNames == null || nodeLibraryNames.Contains(assem.FullName);
vm.Assemblies.Add(new PackageAssembly()
Expand Down
6 changes: 3 additions & 3 deletions src/DynamoPackages/PackageLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct LoadPackageParams

public enum AssemblyLoadingState
{
Succes,
Success,
NotManagedAssembly,
AlreadyLoaded
}
Expand Down Expand Up @@ -243,13 +243,13 @@ public Package ScanPackageDirectory(string directory)
/// </summary>
/// <param name="filename">The filename of a DLL</param>
/// <param name="assem">out Assembly - the passed value does not matter and will only be set if loading succeeds</param>
/// <returns>Returns Succes if success, NotManagedAssembly if BadImageFormatException, AlreadyLoaded if FileLoadException</returns>
/// <returns>Returns Success if success, NotManagedAssembly if BadImageFormatException, AlreadyLoaded if FileLoadException</returns>
internal static AssemblyLoadingState TryReflectionOnlyLoadFrom(string filename, out Assembly assem)
{
try
{
assem = Assembly.ReflectionOnlyLoadFrom(filename);
return AssemblyLoadingState.Succes;
return AssemblyLoadingState.Success;
}
catch (BadImageFormatException)
{
Expand Down
21 changes: 21 additions & 0 deletions test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,26 @@ public void SetsErrorState()

}


[Test]
public void NewPackageVersionUpload_DoesNotThrowExceptionWhenDLLIsLoadedSeveralTimes()
{
string packagesDirectory = Path.Combine(TestDirectory, "pkgs");

var loader = new PackageLoader(packagesDirectory);
loader.LoadAll(new LoadPackageParams
{
Preferences = ViewModel.Model.PreferenceSettings
});

PublishPackageViewModel vm = null;
Assert.DoesNotThrow(() =>
{
vm = PublishPackageViewModel.FromLocalPackage(ViewModel, loader.LocalPackages.First());
});

Assert.AreEqual(PackageUploadHandle.State.Error, vm.UploadState);
}

}
}
Binary file added test/pkgs/Custom Rounding/extra/DLL.dll
Binary file not shown.
Binary file not shown.

0 comments on commit 3b1a7c6

Please sign in to comment.