public void DllListing_Equals_Object_Expected_True() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; var expectedChildren = new Collection <IFileListing> { new DllListing { Name = "childNameOne" }, new DllListing { Name = "childNameTwo" } }; var mockDllListingModel = new Mock <IDllListingModel>(); mockDllListingModel.Setup(dllListModel => dllListModel.Name).Returns(expectedName); mockDllListingModel.Setup(dllListModel => dllListModel.FullName).Returns(expectedFullName); mockDllListingModel.Setup(dllListModel => dllListModel.IsDirectory).Returns(expectedIsDirectory); var dllListing = new DllListing(mockDllListingModel.Object) { Children = expectedChildren }; object dllListingObj = dllListing; var isEqual = dllListing.Equals(dllListingObj); Assert.IsTrue(isEqual); }
public void ComPluginSourceDefinition_Validate_FileSystemAssemblyName() { const string expectedComName = "testComName"; const string expectedClsId = "testClsId"; const bool expectedIs32Bit = false; var expectedResourceID = Guid.NewGuid(); const string expectedSavePath = ""; const string expectedResourceName = "testResource"; var mockComPlugin = new Mock <IComPlugin>(); mockComPlugin.Setup(comPlugin => comPlugin.ComName).Returns(expectedComName); mockComPlugin.Setup(comPlugin => comPlugin.ClsId).Returns(expectedClsId); mockComPlugin.Setup(comPlugin => comPlugin.Is32Bit).Returns(expectedIs32Bit); mockComPlugin.Setup(comPlugin => comPlugin.ResourceID).Returns(expectedResourceID); mockComPlugin.Setup(comPlugin => comPlugin.ResourceName).Returns(expectedResourceName); var fileListing = new DllListing { Name = expectedComName, ClsId = expectedClsId, Children = new Collection <IFileListing>(), IsDirectory = false }; var comPluginSourceDefinition = new ComPluginSourceDefinition(mockComPlugin.Object); Assert.AreEqual(fileListing, comPluginSourceDefinition.SelectedDll); Assert.AreEqual(expectedResourceID, comPluginSourceDefinition.Id); Assert.AreEqual(expectedSavePath, comPluginSourceDefinition.ResourcePath); Assert.AreEqual(expectedClsId, comPluginSourceDefinition.ClsId); Assert.AreEqual(expectedIs32Bit, comPluginSourceDefinition.Is32Bit); Assert.AreEqual(expectedResourceName, comPluginSourceDefinition.ResourceName); }
public void DllListing_Equals_FileListing_Expected_False() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; var mockDllListingModel = new Mock <IDllListingModel>(); mockDllListingModel.Setup(dllListModel => dllListModel.Name).Returns(expectedName); mockDllListingModel.Setup(dllListModel => dllListModel.FullName).Returns(expectedFullName); mockDllListingModel.Setup(dllListModel => dllListModel.IsDirectory).Returns(expectedIsDirectory); var dllListing = new DllListing(mockDllListingModel.Object); var mockDllListingModelDup = new Mock <IDllListingModel>(); mockDllListingModelDup.Setup(dllListModel => dllListModel.Name).Returns("testNewName"); mockDllListingModelDup.Setup(dllListModel => dllListModel.FullName).Returns(expectedFullName); mockDllListingModelDup.Setup(dllListModel => dllListModel.IsDirectory).Returns(expectedIsDirectory); var dllListingDup = new DllListing(mockDllListingModelDup.Object); var isEqual = dllListing.Equals(dllListingDup); Assert.IsFalse(isEqual); Assert.IsTrue(dllListing != dllListingDup); }
public void DllListing_GetHashCode_Not_Equal_To_Zero() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; var expectedChildren = new Collection <IFileListing> { new FileListing { Name = "childNameOne" }, new FileListing { Name = "childNameTwo" } }; var mockDllListingModel = new Mock <IDllListingModel>(); mockDllListingModel.Setup(dllListModel => dllListModel.Name).Returns(expectedName); mockDllListingModel.Setup(dllListModel => dllListModel.FullName).Returns(expectedFullName); mockDllListingModel.Setup(dllListModel => dllListModel.IsDirectory).Returns(expectedIsDirectory); var dllListing = new DllListing(mockDllListingModel.Object) { Children = expectedChildren }; var hashCode = dllListing.GetHashCode(); Assert.AreNotEqual(0, hashCode); }
static DllListing BuildDllListing(FileSystemInfo fileInfo) { var dllListing = new DllListing { Name = fileInfo.Name, FullName = fileInfo.FullName }; return(dllListing); }
public void DllListing_GetHashCode_Expect_Zero() { var dllListing = new DllListing(); var hashCode = dllListing.GetHashCode(); Assert.AreEqual(0, hashCode); }
static List <IFileListing> GetDllListing(IFileListing src) { var completeList = new List <IFileListing>(); var fileSystemParent = new DllListing { Name = "File System", IsDirectory = true }; var gacItem = new DllListing { Name = "GAC", IsDirectory = true }; if (src == null) { var drives = DriveInfo.GetDrives().Where(info => info.DriveType != DriveType.CDRom && info.DriveType != DriveType.Removable); try { var listing = drives.Select(BuildDllListing); fileSystemParent.Children = listing.ToList(); } catch (Exception e) { Dev2Logger.Error(e.Message, GlobalConstants.WarewolfError); } var enumAssembly = new AssemblyCacheEnumerator(); var assemblyName = enumAssembly.GetNextAssembly(); var gacList = new List <IFileListing>(); while (assemblyName != null) { // Create the assembly description. try { var displayName = new AssemblyDescription(assemblyName).DisplayName; var name = GlobalConstants.GACPrefix + displayName; gacList.Add(new DllListing { Name = displayName, FullName = name, IsDirectory = false }); } catch (Exception e) { Dev2Logger.Error(e.Message, GlobalConstants.WarewolfError); } // Create an assembly view model. assemblyName = enumAssembly.GetNextAssembly(); } gacItem.Children = gacList; completeList.Add(fileSystemParent); completeList.Add(gacItem); } else { if (src.IsDirectory) { completeList = GetChildrenForDllListing(new DirectoryInfo(src.FullName)); } } return(completeList); }
public void DllListing_GetHashCode_CorrectlyHashedObject() { var dllListing = new DllListing { Name = "Development", ClsId = "DevClsid" }; Assert.AreEqual(-1908201757, dllListing.GetHashCode(), "Cannot get correct hash code for this object."); }
public void DllListing_Equals_Object_Null_Expected_False() { var dllListing = new DllListing(); const object dllListingObj = null; var isEqual = dllListing.Equals(dllListingObj); Assert.IsFalse(isEqual); }
public void DllListing_NotEqualsOperator_WithNotEqualObjects_AreNotEqual() { var firstDllListing = new DllListing { Name = "bravo" }; var secondDllListing = new DllListing { Name = "charlie" }; Assert.IsTrue(firstDllListing != secondDllListing, "Not equals operator doesnt work."); }
public void DllListing_EqualsOperator_WithEqualObjects_AreEqual() { var firstDllListing = new DllListing { Name = "bravo" }; var secondDllListing = new DllListing { Name = "bravo" }; Assert.IsTrue(firstDllListing == secondDllListing, "Equals operator doesnt work."); }
public PluginSourceDefinition(IPlugin db) { SelectedDll = new DllListing { FullName = db.AssemblyLocation, Name = db.AssemblyName, Children = new Collection <IFileListing>(), IsDirectory = false }; Id = db.ResourceID; Path = db.GetSavePath(); Name = db.ResourceName; ConfigFilePath = db.ConfigFilePath; SetAssemblyName(db); }
public ComPluginSourceDefinition(IComPlugin db) { SelectedDll = new DllListing { Name = db.ComName, ClsId = db.ClsId, Is32Bit = db.Is32Bit, Children = new Collection <IFileListing>(), IsDirectory = false }; Id = db.ResourceID; ResourcePath = ""; ClsId = db.ClsId; Is32Bit = db.Is32Bit; ResourceName = db.ResourceName; }
public void DllListing_ReferenceEquals_DllListing_Expected_True() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; var mockDllListingModel = new Mock <IDllListingModel>(); mockDllListingModel.Setup(dllListModel => dllListModel.Name).Returns(expectedName); mockDllListingModel.Setup(dllListModel => dllListModel.FullName).Returns(expectedFullName); mockDllListingModel.Setup(dllListModel => dllListModel.IsDirectory).Returns(expectedIsDirectory); var dllListing = new DllListing(mockDllListingModel.Object); var isEqual = dllListing.Equals(dllListing); Assert.IsTrue(isEqual); }
public void DllListing_Equals_Object_GetType_Expected_False() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; var mockDllListingModel = new Mock <IDllListingModel>(); mockDllListingModel.Setup(dllListModel => dllListModel.Name).Returns(expectedName); mockDllListingModel.Setup(dllListModel => dllListModel.FullName).Returns(expectedFullName); mockDllListingModel.Setup(dllListModel => dllListModel.IsDirectory).Returns(expectedIsDirectory); var dllListing = new DllListing(mockDllListingModel.Object); var dllListingObj = new object(); var isEqual = dllListing.Equals(dllListingObj); Assert.IsFalse(isEqual); }
public void DllListing_Validate() { const string expectedName = "testName"; const string expectedFullName = "testFullName"; const bool expectedIsDirectory = false; const string expectedClsId = "testClsId"; const bool expectedIs32Bit = false; var expectedChildren = new Collection <IFileListing> { new FileListing { Name = "childNameOne" }, new FileListing { Name = "childNameTwo" } }; var mockDllListingModel = new Mock <IDllListingModel>(); mockDllListingModel.Setup(dllListModel => dllListModel.Name).Returns(expectedName); mockDllListingModel.Setup(dllListModel => dllListModel.FullName).Returns(expectedFullName); mockDllListingModel.Setup(dllListModel => dllListModel.IsDirectory).Returns(expectedIsDirectory); mockDllListingModel.Setup(dllListModel => dllListModel.ClsId).Returns(expectedClsId); mockDllListingModel.Setup(dllListModel => dllListModel.Is32Bit).Returns(expectedIs32Bit); var dllListing = new DllListing(mockDllListingModel.Object) { Children = expectedChildren }; Assert.AreEqual(expectedName, dllListing.Name); Assert.AreEqual(expectedFullName, dllListing.FullName); Assert.AreEqual(expectedIsDirectory, dllListing.IsDirectory); Assert.AreEqual(2, dllListing.Children.Count); Assert.AreEqual("childNameOne", dllListing.Children.ToList()[0].Name); Assert.AreEqual("childNameTwo", dllListing.Children.ToList()[1].Name); Assert.AreEqual(expectedClsId, dllListing.ClsId); Assert.AreEqual(expectedIs32Bit, dllListing.Is32Bit); }
public void PluginSourceDefinition_Validate_GACAssemblyName() { const string expectedAssemblyLocation = "GAC:testAssemblyPath"; const string expectedAssemblyName = "testAssemblyName"; var expectedResourceID = Guid.NewGuid(); const string expectedSavePath = "Path\\ResourcePath"; const string expectedResourceName = "testResource"; const string expectedConfigFilePath = "testConfigFilePath"; var mockPlugin = new Mock <IPlugin>(); mockPlugin.Setup(plugin => plugin.AssemblyLocation).Returns(expectedAssemblyLocation); mockPlugin.Setup(plugin => plugin.AssemblyName).Returns(expectedAssemblyName); mockPlugin.Setup(plugin => plugin.ResourceID).Returns(expectedResourceID); mockPlugin.Setup(plugin => plugin.GetSavePath()).Returns(expectedSavePath); mockPlugin.Setup(plugin => plugin.ResourceName).Returns(expectedResourceName); mockPlugin.Setup(plugin => plugin.ConfigFilePath).Returns(expectedConfigFilePath); var fileListing = new DllListing { FullName = expectedAssemblyLocation, Name = expectedAssemblyName, Children = new Collection <IFileListing>(), IsDirectory = false }; var pluginSourceDefinition = new PluginSourceDefinition(mockPlugin.Object); Assert.AreEqual(fileListing, pluginSourceDefinition.SelectedDll); Assert.AreEqual(expectedResourceID, pluginSourceDefinition.Id); Assert.AreEqual(expectedSavePath, pluginSourceDefinition.Path); Assert.AreEqual(expectedResourceName, pluginSourceDefinition.Name); Assert.AreEqual(expectedConfigFilePath, pluginSourceDefinition.ConfigFilePath); Assert.AreEqual(string.Empty, pluginSourceDefinition.FileSystemAssemblyName); Assert.AreEqual(expectedAssemblyLocation, pluginSourceDefinition.GACAssemblyName); }
static IList <IFileListing> BuildBaseListing() { var listing = new List <IFileListing>(); var fileSystemListing = new DllListing { FullName = "", IsDirectory = true, Name = "File System" }; _dllListingForGac = new DllListing { FullName = "GAC:AuditPolicyGPManagedStubs, Version=6.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", IsDirectory = false, Name = "AuditPolicyGPManagedStubs.Interop, Version=6.1.0.0" }; var gacListing = new DllListing { FullName = "", IsDirectory = true, Name = "GAC", Children = new List <IFileListing> { _dllListingForGac, new DllListing { FullName = "GAC:vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", IsDirectory = false, Name = "vjslib, Version=2.0.0.0" } } }; var gacFilterListing = new DllListing { FullName = "", IsDirectory = true, Name = "GAC", Children = new List <IFileListing> { _dllListingForGac, new DllListing { FullName = "GAC:BDATunePIA, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.dll", IsDirectory = false, Name = "BDATunePIA, Version=6.1.0.0" } } }; _dllListingForFile = new DllListing { FullName = "C:\\Development\\Dev\\Binaries\\MS Fakes\\Microsoft.QualityTools.Testing.Fakes.dll", IsDirectory = false, Name = "Microsoft.QualityTools.Testing.Fakes.dll" }; var cDrive = new DllListing { FullName = "C:\\", IsDirectory = true, Name = "C:\\", Children = new List <IFileListing> { new DllListing { FullName = "C:\\Development", IsDirectory = true, Name = "Development", Children = new List <IFileListing> { new DllListing { FullName = "C:\\Development\\Dev", IsDirectory = true, Name = "Dev", Children = new List <IFileListing> { new DllListing { FullName = "C:\\Development\\Dev\\Binaries", IsDirectory = true, Name = "Binaries", Children = new List <IFileListing> { new DllListing { FullName = "C:\\Development\\Dev\\Binaries\\MS Fakes", IsDirectory = true, Name = "MS Fakes", Children = new List <IFileListing> { _dllListingForFile, new DllListing { FullName = "C:\\Development\\Dev\\Binaries\\MS Fakes\\Dev2.Common.dll", IsDirectory = false, Name = "Dev2.Common.dll" } } } } } } } } } } }; var dDrive = new DllListing { FullName = "D:\\", IsDirectory = true, Name = "D:\\" }; fileSystemListing.Children = new List <IFileListing> { cDrive, dDrive }; listing.Add(fileSystemListing); listing.Add(gacListing); listing.Add(gacFilterListing); return(listing); }