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>(); }
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); }
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); }
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); }