Beispiel #1
0
        public void AboutWindowFactory_IsExportedViaMef()
        {
            var container = MefTestUtils.CreateMefContainer();
            var mefImport = new MefImportTestHelper();

            container.ComposeParts(mefImport);

            Assert.IsNotNull(mefImport.Target);
        }
Beispiel #2
0
        public void AboutWindowFactory_ImplementsFactoryT1Interface()
        {
            var container = MefTestUtils.CreateMefContainer();
            var mefImport = new MefImportTestHelper();

            container.ComposeParts(mefImport);

            Assert.IsNotNull(mefImport.Target);
            Assert.IsInstanceOfType(mefImport.Target, typeof(IFactory <AboutWindow>));
        }
Beispiel #3
0
        public void AboutWindowFactory_Get_DoesNotReturnNull()
        {
            var container = MefTestUtils.CreateMefContainer();
            var mefImport = new MefImportTestHelper();

            container.ComposeParts(mefImport);

            var instance = mefImport.Target.Get();

            Assert.IsNotNull(instance);
        }
Beispiel #4
0
        public void AboutWindowFactory_Get_Max1UniqueInstance()
        {
            var container = MefTestUtils.CreateMefContainer();
            var mefImport = new MefImportTestHelper();

            container.ComposeParts(mefImport);

            var expected = mefImport.Target.Get();
            var actual   = mefImport.Target.Get();

            Assert.AreSame(expected, actual);
        }
Beispiel #5
0
        public void AboutWindowFactory_Get_HasExpectedDataContext()
        {
            var container = MefTestUtils.CreateMefContainer();
            var mefImport = new MefImportTestHelper();

            container.ComposeParts(mefImport);
            var expected = mefImport.ViewModel;

            var instance = mefImport.Target.Get();

            var actual = instance.DataContext as AboutViewModel;

            Assert.IsNotNull(actual);
            Assert.AreSame(expected, actual);
        }
Beispiel #6
0
        public void AboutWindowFactory_Get_ReturnsNewInstanceIfWindowWasClosed()
        {
            var container = MefTestUtils.CreateMefContainer();
            var mefImport = new MefImportTestHelper();

            container.ComposeParts(mefImport);
            var notExpected = mefImport.Target.Get();

            notExpected.Close();

            var actual = mefImport.Target.Get();

            Assert.AreNotSame(notExpected, actual);
            Assert.IsNotNull(notExpected);
            Assert.IsNotNull(actual);
        }