-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from FH-Inway/fix-pr27-regression
add features to support dataverse edmx files, improve performance and maintainability
- Loading branch information
Showing
8 changed files
with
835 additions
and
79 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" /> | ||
<PackageReference Include="NUnit" Version="3.13.3" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" /> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" /> | ||
<PackageReference Include="NunitXml.TestLogger" Version="3.1.15" /> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EDMXTrimmer\EDMXTrimmer.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="TripPin.xml" > | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
</Project> |
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,176 @@ | ||
using NUnit.Framework; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using EDMXTrimmer; | ||
|
||
namespace EDMXTrimmer.Tests | ||
{ | ||
public class EdmxTrimmerTests | ||
{ | ||
private const string TestEdmxFile = "TripPin.xml"; | ||
private const string TestOutputFile = "TripPin-Trimmed.xml"; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
|
||
} | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
// Delete the test EDMX file and output file | ||
File.Delete(TestOutputFile); | ||
} | ||
|
||
[Test] | ||
public void TestEdmxTrimmer() | ||
{ | ||
// Arrange | ||
var entitiesToKeep = new List<string> { "Photos", "People" }; | ||
var entitiesToExclude = new List<string> { "People" }; | ||
var edmxTrimmer = new EdmxTrimmer(TestEdmxFile, TestOutputFile, true, entitiesToKeep, entitiesToExclude); | ||
|
||
// Act | ||
edmxTrimmer.AnalyzeFile(); | ||
|
||
// Assert | ||
Assert.That(File.Exists(TestOutputFile), Is.True); | ||
|
||
var trimmedEdmx = File.ReadAllText(TestOutputFile); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(trimmedEdmx, Does.Contain("<EntitySet Name=\"Photos\"")); | ||
Assert.That(trimmedEdmx, Does.Contain("<EntityType Name=\"Photo\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntitySet Name=\"People\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntityType Name=\"Person\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntitySet Name=\"Airlines\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntityType Name=\"Airline\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntitySet Name=\"Airports\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntityType Name=\"Airport\"")); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void TestEdmxTrimmer_NoEntitiesToKeepOrExclude() | ||
{ | ||
// Arrange | ||
var edmxTrimmer = new EdmxTrimmer(TestEdmxFile, TestOutputFile); | ||
|
||
// Act | ||
edmxTrimmer.AnalyzeFile(); | ||
|
||
// Assert | ||
Assert.That(File.Exists(TestOutputFile), Is.True); | ||
|
||
var trimmedEdmx = File.ReadAllText(TestOutputFile); | ||
Assert.That(trimmedEdmx, Is.EqualTo(File.ReadAllText(TestEdmxFile))); | ||
} | ||
|
||
[Test] | ||
public void TestEdmxTrimmer_RemovePrimaryAnnotations() | ||
{ | ||
// Arrange | ||
var edmxTrimmer = new EdmxTrimmer(TestEdmxFile, TestOutputFile, removePrimaryAnnotations: true); | ||
|
||
// Act | ||
edmxTrimmer.AnalyzeFile(); | ||
|
||
// Assert | ||
Assert.That(File.Exists(TestOutputFile), Is.True); | ||
|
||
var trimmedEdmx = File.ReadAllText(TestOutputFile); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("Primary")); | ||
} | ||
|
||
[Test] | ||
public void TestEdmxTrimmer_RemoveActionImports() | ||
{ | ||
// Arrange | ||
var edmxTrimmer = new EdmxTrimmer(TestEdmxFile, TestOutputFile, removeActionImports: true); | ||
|
||
// Act | ||
edmxTrimmer.AnalyzeFile(); | ||
|
||
// Assert | ||
Assert.That(File.Exists(TestOutputFile), Is.True); | ||
|
||
var trimmedEdmx = File.ReadAllText(TestOutputFile); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("ActionImport")); | ||
} | ||
|
||
[Test] | ||
public void TestEdmxTrimmer_RemoveFunctionImports() | ||
{ | ||
// Arrange | ||
var edmxTrimmer = new EdmxTrimmer(TestEdmxFile, TestOutputFile) | ||
{ | ||
RemoveFunctionImportsFlag = true | ||
}; | ||
|
||
|
||
// Act | ||
edmxTrimmer.AnalyzeFile(); | ||
|
||
// Assert | ||
Assert.That(File.Exists(TestOutputFile), Is.True); | ||
|
||
var trimmedEdmx = File.ReadAllText(TestOutputFile); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("FunctionImport")); | ||
} | ||
|
||
[Test] | ||
public void TestEdmxTrimmer_RemoveComplexTypes() | ||
{ | ||
// Arrange | ||
var edmxTrimmer = new EdmxTrimmer(TestEdmxFile, TestOutputFile) | ||
{ | ||
RemoveComplexTypesFlag = true | ||
}; | ||
|
||
// Act | ||
edmxTrimmer.AnalyzeFile(); | ||
|
||
// Assert | ||
Assert.That(File.Exists(TestOutputFile), Is.True); | ||
|
||
var trimmedEdmx = File.ReadAllText(TestOutputFile); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("ComplexType")); | ||
} | ||
|
||
[Test] | ||
public void TestEdmxTrimmer_EntitiesAreRegularExpressions() | ||
{ | ||
// Arrange | ||
|
||
var entitiesToKeep = new List<string> { @"\b\w+s\b" }; // Keep entities that end with "s" | ||
var entitiesToExclude = new List<string> { @"P\w+" }; // Exclude entities that start with "P" | ||
var edmxTrimmer = new EdmxTrimmer( | ||
TestEdmxFile, | ||
TestOutputFile, | ||
entitiesAreRegularExpressions: true, | ||
entitiesToKeep: entitiesToKeep, | ||
entitiesToExclude: entitiesToExclude); | ||
|
||
// Act | ||
edmxTrimmer.AnalyzeFile(); | ||
|
||
// Assert | ||
Assert.That(File.Exists(TestOutputFile), Is.True); | ||
|
||
var trimmedEdmx = File.ReadAllText(TestOutputFile); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntitySet Name=\"Photos\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntityType Name=\"Photo\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntitySet Name=\"People\"")); | ||
Assert.That(trimmedEdmx, Does.Not.Contain("<EntityType Name=\"Person\"")); | ||
Assert.That(trimmedEdmx, Does.Contain("<EntitySet Name=\"Airlines\"")); | ||
Assert.That(trimmedEdmx, Does.Contain("<EntityType Name=\"Airline\"")); | ||
Assert.That(trimmedEdmx, Does.Contain("<EntitySet Name=\"Airports\"")); | ||
Assert.That(trimmedEdmx, Does.Contain("<EntityType Name=\"Airport\"")); | ||
}); | ||
} | ||
} | ||
} |
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 @@ | ||
global using NUnit.Framework; |
Oops, something went wrong.