コード例 #1
0
        public void WhenInstanceCannotBeResolved_ThrowsException()
        {
            // Arrange
            ContainerBuilder builder   = new ContainerBuilder();
            IContainer       container = builder.Build();

            OWRankTracker.Services.Wpf.WindowService service = new OWRankTracker.Services.Wpf.WindowService(container);

            // Act
            service.ShowWindow <FakeWindow>();
        }
コード例 #2
0
        public void ShowsTheWindowBeforeReturningIt()
        {
            // Arrange
            FakeWindow window = new FakeWindow();

            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterInstance(window);
            IContainer container = builder.Build();

            OWRankTracker.Services.Wpf.WindowService service = new OWRankTracker.Services.Wpf.WindowService(container);

            // Act
            FakeWindow actual = service.ShowWindow <FakeWindow>();

            // Assert
            Assert.IsTrue(actual.IsVisible);
        }
コード例 #3
0
        public void UsesTheInjectedContainer_ToGetANewInstanceOfTheWindowType()
        {
            // Arrange
            FakeWindow window = new FakeWindow();

            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterInstance(window);
            IContainer container = builder.Build();

            OWRankTracker.Services.Wpf.WindowService service = new OWRankTracker.Services.Wpf.WindowService(container);

            // Act
            FakeWindow actual = service.ShowWindow <FakeWindow>();

            // Assert
            Assert.AreSame(window, actual);
        }
コード例 #4
0
        public void ShowWindow_WithOwner_SetsTheArgumentAsTheOwnerOfTheResolvedWindow()
        {
            // Arrange
            FakeWindow window = new FakeWindow();
            FakeWindow parent = new FakeWindow();

            parent.Show(); // A parent window must be shown

            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterInstance(window);
            IContainer container = builder.Build();

            OWRankTracker.Services.Wpf.WindowService service = new OWRankTracker.Services.Wpf.WindowService(container);

            // Act
            FakeWindow actual = service.ShowWindow <FakeWindow>(parent);

            // Assert
            Assert.AreEqual(actual.Owner, parent);
        }