Index: Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs =================================================================== diff -u -r64a0676b0e2fbfea7a17f8074ee35550b9cf9b99 -r3414de3ddc243dfd52962807b614d05885764591 --- Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision 64a0676b0e2fbfea7a17f8074ee35550b9cf9b99) +++ Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision 3414de3ddc243dfd52962807b614d05885764591) @@ -93,7 +93,7 @@ } [Test] - public void GetSupportedImportInfos_NoImportInfosForTarget_ReturnsEmptyEnumeration() + public void GetSupportedImportInfos_NoImportInfos_ReturnsEmptyEnumeration() { // Setup var mocks = new MockRepository(); @@ -112,11 +112,86 @@ } [Test] + public void GetSupportedImportInfos_NoImportInfosForTargetType_ReturnsEmptyEnumeration() + { + // Setup + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + var inquiryHelper = mocks.Stub(); + mocks.ReplayAll(); + + var commandHandler = new GuiImportHandler(dialogParent, new ImportInfo[] + { + new ImportInfo(), + new ImportInfo() + }, inquiryHelper); + + // Call + IEnumerable supportedImportInfos = commandHandler.GetSupportedImportInfos(new TestClassC()); + + // Assert + CollectionAssert.IsEmpty(supportedImportInfos); + mocks.VerifyAll(); + } + + [Test] + public void GetSupportedImportInfos_MultipleImportInfos_ReturnsEnumerationBasedOnTargetType() + { + // Setup + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + var inquiryHelper = mocks.Stub(); + mocks.ReplayAll(); + + var firstImportInfo = new ImportInfo + { + Name = "1" + }; + + var secondImportInfo = new ImportInfo + { + Name = "2" + }; + + var thirdImportInfo = new ImportInfo + { + Name = "3" + }; + + var fourthImportInfo = new ImportInfo + { + Name = "4" + }; + + var commandHandler = new GuiImportHandler(dialogParent, new ImportInfo[] + { + firstImportInfo, + secondImportInfo, + thirdImportInfo, + fourthImportInfo + }, inquiryHelper); + + // Call + IEnumerable supportedImportInfos = commandHandler.GetSupportedImportInfos(new TestClassB()); + + // Assert + var expectedImportInfos = new List + { + firstImportInfo, + secondImportInfo, + fourthImportInfo + }; + + CollectionAssert.AreEqual(expectedImportInfos, supportedImportInfos, new ImportInfoNameComparer()); + mocks.VerifyAll(); + } + + [Test] [TestCase(true, true)] [TestCase(true, false)] [TestCase(false, true)] [TestCase(false, false)] - public void GetSupportedImportInfos_MultipleImportInfosForTarget_ReturnsEnumerationBasedOnEnabledState( + public void GetSupportedImportInfos_MultipleImportInfosForTargetType_ReturnsEnumerationBasedOnEnabledState( bool firstImportInfoEnabled, bool secondImportInfoEnabled) { @@ -436,6 +511,12 @@ mockRepository.VerifyAll(); } + private class TestClassA {} + + private class TestClassB : TestClassA {} + + private class TestClassC {} + private class ImportInfoNameComparer : IComparer { public int Compare(object x, object y)