示例#1
0
        public void GetSupportedImportInfos_MultipleImportInfos_ReturnsEnumerationBasedOnTargetType()
        {
            // Setup
            var mocks         = new MockRepository();
            var dialogParent  = mocks.Stub <IViewParent>();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            var firstImportInfo = new ImportInfo <TestClassA>
            {
                Name = "1"
            };

            var secondImportInfo = new ImportInfo <TestClassB>
            {
                Name = "2"
            };

            var thirdImportInfo = new ImportInfo <TestClassC>
            {
                Name = "3"
            };

            var fourthImportInfo = new ImportInfo <TestClassB>
            {
                Name = "4"
            };

            var commandHandler = new GuiImportHandler(dialogParent, new ImportInfo[]
            {
                firstImportInfo,
                secondImportInfo,
                thirdImportInfo,
                fourthImportInfo
            }, inquiryHelper);

            // Call
            IEnumerable <ImportInfo> supportedImportInfos = commandHandler.GetSupportedImportInfos(new TestClassB());

            // Assert
            var expectedImportInfos = new List <ImportInfo>
            {
                firstImportInfo,
                secondImportInfo,
                fourthImportInfo
            };

            CollectionAssert.AreEqual(expectedImportInfos, supportedImportInfos, new ImportInfoNameComparer());
            mocks.VerifyAll();
        }
示例#2
0
        public void GetSupportedImportInfos_MultipleImportInfosForTargetType_ReturnsEnumerationBasedOnEnabledState(
            bool firstImportInfoEnabled,
            bool secondImportInfoEnabled)
        {
            // Setup
            var mocks         = new MockRepository();
            var dialogParent  = mocks.Stub <IViewParent>();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            var firstImportInfo = new ImportInfo <object>
            {
                Name      = "1",
                IsEnabled = o => firstImportInfoEnabled
            };

            var secondImportInfo = new ImportInfo <object>
            {
                Name      = "2",
                IsEnabled = o => secondImportInfoEnabled
            };

            var commandHandler = new GuiImportHandler(dialogParent, new ImportInfo[]
            {
                firstImportInfo,
                secondImportInfo
            }, inquiryHelper);

            // Call
            IEnumerable <ImportInfo> supportedImportInfos = commandHandler.GetSupportedImportInfos(new object());

            // Assert
            var expectedImportInfos = new List <ImportInfo>();

            if (firstImportInfoEnabled)
            {
                expectedImportInfos.Add(firstImportInfo);
            }

            if (secondImportInfoEnabled)
            {
                expectedImportInfos.Add(secondImportInfo);
            }

            CollectionAssert.AreEqual(expectedImportInfos, supportedImportInfos, new ImportInfoNameComparer());
            mocks.VerifyAll();
        }
示例#3
0
        public void GetSupportedImportInfos_NoImportInfos_ReturnsEmptyEnumeration()
        {
            // Setup
            var mocks         = new MockRepository();
            var dialogParent  = mocks.Stub <IViewParent>();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            var commandHandler = new GuiImportHandler(dialogParent, Enumerable.Empty <ImportInfo>(), inquiryHelper);

            // Call
            IEnumerable <ImportInfo> supportedImportInfos = commandHandler.GetSupportedImportInfos(new object());

            // Assert
            CollectionAssert.IsEmpty(supportedImportInfos);
            mocks.VerifyAll();
        }
示例#4
0
        public void GetSupportedImportInfos_NoImportInfosForTargetType_ReturnsEmptyEnumeration()
        {
            // Setup
            var mocks         = new MockRepository();
            var dialogParent  = mocks.Stub <IViewParent>();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            var commandHandler = new GuiImportHandler(dialogParent, new ImportInfo[]
            {
                new ImportInfo <TestClassA>(),
                new ImportInfo <TestClassB>()
            }, inquiryHelper);

            // Call
            IEnumerable <ImportInfo> supportedImportInfos = commandHandler.GetSupportedImportInfos(new TestClassC());

            // Assert
            CollectionAssert.IsEmpty(supportedImportInfos);
            mocks.VerifyAll();
        }