Beispiel #1
0
        public void WindowHasCorrectDataContext(WindowInitiator sut, object dataContext)
        {
            var windowType = typeof(FakeWindow);
            var actual     = sut.Initialize(windowType, dataContext, null);

            Assert.Same(dataContext, actual.DataContext);
        }
Beispiel #2
0
        public void WindowTypeIsCorrect(WindowInitiator sut)
        {
            var windowType = typeof(FakeWindow);
            var actual     = sut.Initialize(windowType, null, null);

            Assert.IsType <FakeWindow>(actual);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the App class.
        /// </summary>
        public App()
        {
            try
            {
                var assembly = Assembly.GetEntryAssembly();
                IWindowInitiator initiator = new WindowInitiator();
                IMetric          metric    = new Levenshtein();

                // Add services to the Ioc container.
                Ioc.Current.RegisterAsSingleton <IWindowLocator>(new WindowLocator(assembly, initiator, metric));
                //Ioc.Current.RegisterAsSingleton<IEventAggregator>(new EventAggregator());

                // Register windows in the WindowLocator service.
                var windowLocator = Ioc.Current.Resolve <IWindowLocator>();
                windowLocator.RegisterAll();

                // Shows the main window.
                windowLocator.ShowWindow(new MainViewModel());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
            }
        }
Beispiel #4
0
        public void WindowHasCorrectOwner(WindowInitiator sut)
        {
            var windowType  = typeof(FakeWindow);
            var ownerWindow = new FakeWindow {
                WindowState = WindowState.Minimized
            };

            ownerWindow.Show();

            var actual = sut.Initialize(windowType, null, ownerWindow);

            Assert.Same(ownerWindow, actual.Owner);
        }
Beispiel #5
0
 public void NullWindowTypeThrowsException(WindowInitiator sut, object dataContext, Mock <Window> mockOwnerWindow)
 {
     Assert.Throws <ArgumentNullException>(() => sut.Initialize(null, dataContext, mockOwnerWindow.Object));
 }