Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 committed Jan 1, 2025
1 parent 7e45d93 commit a83946e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 57 deletions.
21 changes: 6 additions & 15 deletions test/DynamoCoreTests/DynamoCoreTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="2.0.226801" GeneratePathProperty="true" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\DynamoCore\DynamoCore.csproj">
Expand Down Expand Up @@ -139,18 +138,10 @@
<ItemGroup>
<Folder Include="NodesJsonDatasets\" />
</ItemGroup>
<Target Name="CopyDisableADPTestDeps">
<!--ms diag runtime + deps -->
<Message Importance="High" Text="copying disable adp test deps to test dependencies folder" />
<Copy SourceFiles="$(PkgMicrosoft_Diagnostics_Runtime)\lib\netstandard2.0\Microsoft.Diagnostics.Runtime.dll" DestinationFolder="$(TestDependenciesPath)" />
</Target>

<Target Name="MoveSomeTestDepsOutOfBin" AfterTargets="Build">
<Message Importance="High" Text="copying test dependencies to test dependencies folder" />
<CallTarget Targets="CopyDisableADPTestDeps"></CallTarget>
<!--moq + deps-->
<Copy SourceFiles="$(PkgCastle_Core)\lib\netstandard2.0\Castle.Core.dll" DestinationFolder="$(TestDependenciesPath)" />
<Copy SourceFiles="$(PkgMoq)\lib\netstandard2.0\Moq.dll" DestinationFolder="$(TestDependenciesPath)" />
<Copy SourceFiles="$(PkgMoq)\lib\netstandard2.0\Moq.dll" DestinationFolder="$(OutputPath)" />
</Target>
<Target Name="MoveSomeTestDepsOutOfBin" AfterTargets="Build">
<!--moq + deps-->
<Copy SourceFiles="$(PkgCastle_Core)\lib\netstandard2.0\Castle.Core.dll" DestinationFolder="$(TestDependenciesPath)" />
<Copy SourceFiles="$(PkgMoq)\lib\netstandard2.0\Moq.dll" DestinationFolder="$(TestDependenciesPath)" />
<Copy SourceFiles="$(PkgMoq)\lib\netstandard2.0\Moq.dll" DestinationFolder="$(OutputPath)" />
</Target>
</Project>
60 changes: 18 additions & 42 deletions test/DynamoCoreTests/Logging/AnalyticsServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Diagnostics.Runtime;
using NUnit.Framework;
using System.Runtime.Versioning;

namespace Dynamo.Tests.Loggings
{
Expand Down Expand Up @@ -41,42 +38,29 @@ public void DisableAnalytics()
{
DynamoShapeManager.Utilities.GetInstalledAsmVersion2(versions, ref locatedPath, coreDirectory);
}

try
{
Assert.DoesNotThrow(() =>
{
dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --DisableAnalytics -o \"{openPath}\" ") { UseShellExecute = true });

dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --DisableAnalytics -o \"{openPath}\" ") { UseShellExecute = true });

Thread.Sleep(5000);// Wait 5 seconds to open the dyn
Assert.IsFalse(dynamoCLI.HasExited);
var dt = DataTarget.AttachToProcess(dynamoCLI.Id, false);
var assemblies = dt
.ClrVersions
.Select(dtClrVersion => dtClrVersion.CreateRuntime())
.SelectMany(runtime => runtime.AppDomains.SelectMany(runtimeAppDomain => runtimeAppDomain.Modules))
.Select(clrModule => clrModule.AssemblyName)
.Distinct()
.Where(x => x != null)
.ToList();
Thread.Sleep(5000);// Wait 5 seconds to open the dyn
Assert.IsFalse(dynamoCLI.HasExited);

var firstASMmodulePath = string.Empty;
foreach (string module in assemblies)
var firstASMmodulePath = string.Empty;
foreach (ProcessModule module in dynamoCLI.Modules)
{
if (module.ModuleName.IndexOf("Analytics.dll", StringComparison.OrdinalIgnoreCase) != -1)
{
if (module.IndexOf("Analytics", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("Analytics module was loaded");
}
if (module.IndexOf("AdpSDKCSharpWrapper", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("ADP module was loaded");
}
Assert.Fail("Analytics module was loaded");
}
});
if (module.ModuleName.IndexOf("AdpSDKCSharpWrapper.dll", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("ADP module was loaded");
}
}
}
finally
{

dynamoCLI?.Kill();
}
}
Expand Down Expand Up @@ -116,25 +100,17 @@ public void DisableAnalyticsViaNoNetWorkMode()
dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --NoNetworkMode -o \"{openPath}\" ") { UseShellExecute = true });

Thread.Sleep(5000);// Wait 5 seconds to open the dyn

Assert.IsFalse(dynamoCLI.HasExited);
var dt = DataTarget.AttachToProcess(dynamoCLI.Id, false);
var assemblies = dt
.ClrVersions
.Select(dtClrVersion => dtClrVersion.CreateRuntime())
.SelectMany(runtime => runtime.AppDomains.SelectMany(runtimeAppDomain => runtimeAppDomain.Modules))
.Select(clrModule => clrModule.AssemblyName)
.Distinct()
.Where(x => x != null)
.ToList();

var firstASMmodulePath = string.Empty;
foreach (string module in assemblies)
foreach (ProcessModule module in dynamoCLI.Modules)
{
if (module.IndexOf("Analytics", StringComparison.OrdinalIgnoreCase) != -1)
if (module.ModuleName.IndexOf("Analytics.dll", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("Analytics module was loaded");
}
if (module.IndexOf("AdpSDKCSharpWrapper", StringComparison.OrdinalIgnoreCase) != -1)
if (module.ModuleName.IndexOf("AdpSDKCSharpWrapper.dll", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("ADP module was loaded");
}
Expand Down

0 comments on commit a83946e

Please sign in to comment.