forked from DynamoDS/Dynamo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDynamoApplicationTests.cs
89 lines (79 loc) · 3.21 KB
/
DynamoApplicationTests.cs
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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Dynamo.Applications;
using Dynamo.Models;
using NUnit.Framework;
namespace IntegrationTests
{
public class DynamoApplicationTests
{
[Test]
public void DynamoSandboxLoadsASMFromValidPath()
{
var versions = new List<Version>(){
new Version(230, 0, 0),
};
//go get a valid asm path.
var locatedPath = string.Empty;
var coreDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Process dynamoSandbox = null;
DynamoShapeManager.Utilities.GetInstalledAsmVersion2(versions, ref locatedPath, coreDirectory);
try
{
Assert.DoesNotThrow(() =>
{
// we use a new process to avoid checking against previously loaded
// asm modules in the nunit-agent process.
dynamoSandbox = System.Diagnostics.Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoSandbox.exe"), $"-gp \"{locatedPath}\""){ UseShellExecute = true });
dynamoSandbox.WaitForInputIdle();
var firstASMmodulePath = string.Empty;
foreach (ProcessModule module in dynamoSandbox.Modules)
{
if (module.FileName.Contains("ASMAHL"))
{
firstASMmodulePath = module.FileName;
break;
}
}
// TODO: This test need to be updated somehow to bypass splash screen
if (!string.IsNullOrEmpty(firstASMmodulePath))
{
//assert that ASM is really loaded from exactly where we specified.
Assert.AreEqual(Path.GetDirectoryName(firstASMmodulePath), locatedPath);
}
});
}
finally
{
dynamoSandbox?.Kill();
}
}
[Test]
public void DynamoMakeModelWithHostName()
{
var model = Dynamo.Applications.StartupUtils.MakeModel(false, string.Empty, "DynamoFormIt");
Assert.AreEqual(DynamoModel.HostAnalyticsInfo.HostName, "DynamoFormIt");
}
[Test]
public void IfASMPathInvalidExceptionNotThrown()
{
var asmMockPath = @"./doesNotExist/";
Assert.DoesNotThrow(() =>
{
var model = StartupUtils.MakeModel(true, asmMockPath);
Assert.IsNotNull(model);
});
}
[Test]
public void GetVersionFromASMPath_returnsFileVersionForMockdll()
{
var version = DynamoShapeManager.Utilities.GetVersionFromPath(@"./", "DynamoCore*.dll");
var thisVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Assert.AreEqual(version.Major, thisVersion.Major);
Assert.AreEqual(version.Minor, thisVersion.Minor);
Assert.AreEqual(version.Build, thisVersion.Build);
}
}
}