public void BuildAssemblyInterfaceData_ForEntityFramework() { var testInterfaceData = new AssemblyInterfaceData(typeof(System.Data.Entity.Database)); var testString = testInterfaceData.GenerateHumanReadableInterfaceDefinition(new NtegrityOutputSettings() { ShowTypesAtOrAboveAccessLevel = AccessLevelEnum.Public }); File.WriteAllText("../../SampleOutput/EntityFramework.Interface.txt", testString); }
public void BuildAssemblyInterfaceData_ForNUnit() { var testInterfaceData = new AssemblyInterfaceData(typeof(TestFixtureAttribute)); var testString = testInterfaceData.GenerateHumanReadableInterfaceDefinition(new NtegrityOutputSettings() { ShowTypesAtOrAboveAccessLevel = AccessLevelEnum.Public }); File.WriteAllText("../../SampleOutput/NUnit.Interface.txt", testString); }
public NtegrityAssemblyDiff(AssemblyInterfaceData oldAssembly, AssemblyInterfaceData newAssembly) { OldAssembly = oldAssembly; NewAssembly = newAssembly; GetAddedAndRemovedClasses(oldAssembly, newAssembly); GetAddedAndRemovedInterfaces(oldAssembly, newAssembly); GetAddedAndRemovedStructs(oldAssembly, newAssembly); GetAddedAndRemovedEnums(oldAssembly, newAssembly); }
public void BuildAssemblyInterfaceData_ExcludePrivate_ReturnsNoPrivateFields() { var SUT = new AssemblyInterfaceData(typeof(PublicClass)); var readable = SUT.GenerateHumanReadableInterfaceDefinition(new NtegrityOutputSettings() { ShowTypesAtOrAboveAccessLevel = AccessLevelEnum.Protected }); Assert.That(readable.IndexOf("private") == -1); }
public void ToString_DoesNotThrow() { var currentDirectory = Directory.GetCurrentDirectory(); var v1Assembly = new AssemblyWrapper(Assembly.LoadFile(currentDirectory + "\\TestAssemblyVersions\\VersionTestAssembly.1.0.0.0.dll")); var v1AssemblyInterfaceData = new AssemblyInterfaceData(v1Assembly); var v2Assembly = new AssemblyWrapper(Assembly.LoadFile(currentDirectory + "\\TestAssemblyVersions\\VersionTestAssembly.2.0.0.0.dll")); var v2AssemblyInterfaceData = new AssemblyInterfaceData(v2Assembly); var SUT = new NtegrityAssemblyDiff(v1AssemblyInterfaceData, v2AssemblyInterfaceData); Assert.That(SUT.ToString() != null); }
public void BuildAssemblyDiff_Forv1Andv2() { var currentDirectory = Directory.GetCurrentDirectory(); var v1Assembly = new AssemblyWrapper(Assembly.LoadFile(currentDirectory + "\\TestAssemblyVersions\\VersionTestAssembly.1.0.0.0.dll")); var v1AssemblyInterfaceData = new AssemblyInterfaceData(v1Assembly); var v2Assembly = new AssemblyWrapper(Assembly.LoadFile(currentDirectory + "\\TestAssemblyVersions\\VersionTestAssembly.2.0.0.0.dll")); var v2AssemblyInterfaceData = new AssemblyInterfaceData(v2Assembly); var SUT = new NtegrityAssemblyDiff(v1AssemblyInterfaceData, v2AssemblyInterfaceData); var readable = SUT.ToString(); File.WriteAllText("../../SampleOutput/AssemblyVersionDiff.txt", readable); }
public void RealDLLTest() { var currentDirectory = Directory.GetCurrentDirectory(); var v1Assembly = new AssemblyWrapper(Assembly.LoadFile(currentDirectory + "\\TestAssemblyVersions\\VersionTestAssembly.1.0.0.0.dll")); var v1AssemblyInterfaceData = new AssemblyInterfaceData(v1Assembly); var v2Assembly = new AssemblyWrapper(Assembly.LoadFile(currentDirectory + "\\TestAssemblyVersions\\VersionTestAssembly.2.0.0.0.dll")); var v2AssemblyInterfaceData = new AssemblyInterfaceData(v2Assembly); var SUT = new NtegrityAssemblyDiff(v1AssemblyInterfaceData, v2AssemblyInterfaceData); Assert.That(SUT != null); Assert.That(SUT.RemovedClasses.Count == 1); Assert.That(SUT.AddedClasses.Count == 1); Assert.That(SUT.RemovedInterfaces.Count == 1); Assert.That(SUT.AddedInterfaces.Count == 1); Assert.That(SUT.RemovedStructs.Count == 1); Assert.That(SUT.AddedStructs.Count == 1); Assert.That(SUT.RemovedEnums.Count == 1); Assert.That(SUT.AddedEnums.Count == 1); }
public void StringOutput_GeneratedTwice_IsIdentical() { var testAssembly = new AssemblyInterfaceData(typeof(PublicClass)); var firstString = testAssembly.GenerateHumanReadableInterfaceDefinition(); var secondPass = new AssemblyInterfaceData(firstString); var secondString = secondPass.GenerateHumanReadableInterfaceDefinition(); Assert.That(firstString.Length == secondString.Length); Assert.That(firstString.Equals(secondString)); }
public void StringOutput_ForNUnit_DoesNotThrow() { var testInterfaceData = new AssemblyInterfaceData(typeof(TestFixtureAttribute)); var testString = testInterfaceData.GenerateHumanReadableInterfaceDefinition(); }
public void StringOutput_ForEntityFramework_DoesNotThrow() { var testInterfaceData = new AssemblyInterfaceData(typeof(System.Data.Entity.Database)); var testString = testInterfaceData.GenerateHumanReadableInterfaceDefinition(); }
private void GetAddedAndRemovedInterfaces(AssemblyInterfaceData oldAssembly, AssemblyInterfaceData newAssembly) { foreach (var oldInterface in oldAssembly.Interfaces) { if (newAssembly.Interfaces.All(x => x.Name != oldInterface.Name)) { RemovedInterfaces.Add(oldInterface); } } foreach (var newInterface in newAssembly.Interfaces) { if (oldAssembly.Interfaces.All(x => x.Name != newInterface.Name)) { AddedInterfaces.Add(newInterface); } } }
public void StringOutput_DoesNotHaveThreeNewlines() { var testInterfaceData = new AssemblyInterfaceData(typeof(PublicClass)); var testString = testInterfaceData.GenerateHumanReadableInterfaceDefinition(); Assert.That(!testString.Contains(Environment.NewLine + Environment.NewLine + Environment.NewLine)); }
private void GetAddedAndRemovedStructs(AssemblyInterfaceData oldAssembly, AssemblyInterfaceData newAssembly) { foreach (var oldStruct in oldAssembly.Structs) { if (newAssembly.Structs.All(x => x.Name != oldStruct.Name)) { RemovedStructs.Add(oldStruct); } } foreach (var oldStruct in newAssembly.Structs) { if (oldAssembly.Structs.All(x => x.Name != oldStruct.Name)) { AddedStructs.Add(oldStruct); } } }
public void BuildAssemblyInterfaceData_ForTargetAssembly() { var SUT = new AssemblyInterfaceData(typeof(PublicClass)); var readable = SUT.GenerateHumanReadableInterfaceDefinition(); File.WriteAllText("../../SampleOutput/TestTargetAssembly.Interface.txt", readable); }
public void StringOutput_DoesNotHaveTwoSpaces() { var testInterfaceData = new AssemblyInterfaceData(typeof(PublicClass)); var testString = testInterfaceData.GenerateHumanReadableInterfaceDefinition(); Assert.That(!testString.Contains(" ")); }
public void StringConstructor_ProperlyParsesOutput() { var testInterfaceData = new AssemblyInterfaceData(typeof(PublicClass)); var testString = testInterfaceData.GenerateHumanReadableInterfaceDefinition(); var SUT = new AssemblyInterfaceData(testString); Assert.That(SUT.Name == testInterfaceData.Name); Assert.That(SUT.Version == testInterfaceData.Version); Assert.That(SUT.CLRVersion == testInterfaceData.CLRVersion); Assert.That(SUT.ReferencedAssemblies.Count == testInterfaceData.ReferencedAssemblies.Count); Assert.That(SUT.ReferencedAssemblies.All(x => testInterfaceData.ReferencedAssemblies.Any(y => y == x))); }
private void GetAddedAndRemovedEnums(AssemblyInterfaceData oldAssembly, AssemblyInterfaceData newAssembly) { foreach (var oldEnum in oldAssembly.Enums) { if (newAssembly.Enums.All(x => x.Name != oldEnum.Name)) { RemovedEnums.Add(oldEnum); } } foreach (var newEnum in newAssembly.Enums) { if (oldAssembly.Enums.All(x => x.Name != newEnum.Name)) { AddedEnums.Add(newEnum); } } foreach (var oldModifiedEnum in oldAssembly.Enums) { var newModifiedEnum = newAssembly.Enums.FirstOrDefault( x => x.Name == oldModifiedEnum.Name); if (newModifiedEnum == null) { continue; } ModifiedEnums.Add(new EnumTypeDiff(oldModifiedEnum, newModifiedEnum)); } }