- dependencytracker.zip
- DependencyTracker
- DependencyTracker.sln
- DependencyTracker.suo
- DependencyTracker
- SampleProjects
- AllCode.jpg
- AllLibraryCode.jpg
- Applications
- Application1
- LibraryCode
- BusinessObject1
- BusinessObject1.suo
- Database
- Documentation
- References
- BusinessObject1.dll
- BusinessObject1.pdb
- Source
- CommonLibrary1
- CommonLibrary1.suo
- Database
- Documentation
- References
- CommonLibrary1.dll
- CommonLibrary1.pdb
- Source
- Test
- vssver2.scc
|
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using CompanyName.DependencyTracker;
namespace TestDependencyFinder
{
[TestFixture]
public class TestDependencyFinder
{
[Test]
[ExpectedException(typeof(System.IO.DirectoryNotFoundException))]
public void TestNotFound()
{
new DependencyFinder(@"Z:\xyz").GetAllProjects();
}
[Test]
public void TestOneFound()
{
DependencyFinder finder = new DependencyFinder(@"..\..\..\SampleProjects\Applications");
ProjectList projects = finder.GetAllProjects();
Assert.AreEqual(1, projects.Count);
Assert.AreEqual(projects.ToString(), "Application1");
}
[Test]
public void TestTwoFound()
{
DependencyFinder finder = new DependencyFinder(@"..\..\..\SampleProjects\LibraryCode");
ProjectList projects = finder.GetAllProjects();
Assert.AreEqual(2, projects.Count);
Assert.AreEqual(projects.ToString(), "CommonLibrary1, BusinessObject1");
}
[Test]
public void TestOneDependency()
{
DependencyFinder finder = new DependencyFinder(@"..\..\..\SampleProjects\LibraryCode\BusinessObject1");
ProjectList projects = finder.GetAllProjects();
Assert.AreEqual(1, projects.Count);
Assert.AreEqual(projects.ToString(), "BusinessObject1");
Assert.AreEqual(1, projects[0].ReferencedProjects.Count); //references library
Assert.AreEqual(0, projects[0].ReferencedProjects[0].ReferencedProjects.Count); //library refers to nothing
}
[Test]
public void TestNestedDependency()
{
DependencyFinder finder = new DependencyFinder(@"..\..\..\SampleProjects\Applications\Application1");
ProjectList projects = finder.GetAllProjects();
Assert.AreEqual(1, projects.Count);
Assert.AreEqual(projects.ToString(), "Application1");
Assert.AreEqual(2, projects[0].ReferencedProjects.Count); //references businessobjects and library
Assert.AreEqual(1, projects[0].ReferencedProjects[0].ReferencedProjects.Count); //busobjs referes to library
}
[Test]
public void TestVisualizeAll() //visualize it, can't really unit test this so output and verify its there
{
DependencyFinder finder = new DependencyFinder(@"..\..\..\SampleProjects");
string TempOutFile = @"..\..\..\SampleProjects\AllCode.jpg"; //System.IO.Path.GetTempFileName();
finder.VisualizeProjects(TempOutFile);
Assert.IsTrue(System.IO.File.Exists(TempOutFile));
System.IO.File.Delete(TempOutFile);
}
[Test]
public void TestVisualizeLibraryCode() //visualize it, can't really unit test this so output and verify its there
{
DependencyFinder finder = new DependencyFinder(@"..\..\..\SampleProjects\LibraryCode");
string TempOutFile = @"..\..\..\SampleProjects\AllLibraryCode.jpg"; //System.IO.Path.GetTempFileName();
finder.VisualizeProjects(TempOutFile);
Assert.IsTrue(System.IO.File.Exists(TempOutFile));
System.IO.File.Delete(TempOutFile);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been a software developer since 1996 and have enjoyed C# since 2003. I have a Bachelor's degree in Computer Science and for some reason, a Master's degree in Business Administration. I currently do software development contracting/consulting.