Skip to content

Commit

Permalink
chore: fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Aug 15, 2023
1 parent 58f6aa2 commit 5c4867c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void GetErrorsDoesNotThrowException()
{
ContainerLocator.ResetContainer();
var container = Setup.CreateContainer();
ContainerLocator.SetContainerExtension(Setup.Extension);
Assert.False(ContainerLocator.TrySetContainerExtension(Setup.Extension));
Setup.Registry.Register<object, BadView>("BadView");

var ex = Record.Exception(() => container.Resolve<object>("BadView"));
Expand All @@ -60,7 +60,7 @@ public void GetErrorsLocatesIssueWithBadView()
{
ContainerLocator.ResetContainer();
var container = Setup.CreateContainer();
ContainerLocator.SetContainerExtension(Setup.Extension);
Assert.False(ContainerLocator.TrySetContainerExtension(Setup.Extension));
Setup.Registry.Register<object, BadView>("BadView");

var ex = Record.Exception(() => container.Resolve<object>("BadView"));
Expand All @@ -77,7 +77,7 @@ public void GetErrorsLocatesTargetInvocationException()
{
ContainerLocator.ResetContainer();
var container = Setup.CreateContainer();
ContainerLocator.SetContainerExtension(Setup.Extension);
Assert.False(ContainerLocator.TrySetContainerExtension(Setup.Extension));
Setup.Registry.Register<object, BadView>("BadView");

var ex = Record.Exception(() => container.Resolve<object>("BadView"));
Expand All @@ -94,7 +94,7 @@ public void GetErrorsLocatesXamlParseException()
{
ContainerLocator.ResetContainer();
var container = Setup.CreateContainer();
ContainerLocator.SetContainerExtension(Setup.Extension);
Assert.False(ContainerLocator.TrySetContainerExtension(Setup.Extension));
Setup.Registry.Register<object, BadView>("BadView");

var ex = Record.Exception(() => container.Resolve<object>("BadView"));
Expand All @@ -111,7 +111,7 @@ public void LocatesUnregisteredServiceType()
{
ContainerLocator.ResetContainer();
var container = Setup.CreateContainer();
ContainerLocator.SetContainerExtension(Setup.Extension);
Assert.False(ContainerLocator.TrySetContainerExtension(Setup.Extension));

var ex = Record.Exception(() => container.Resolve<ConstructorArgumentViewModel>());

Expand All @@ -127,7 +127,7 @@ public void LocatesUnregisteredServiceWithMissingRegistration()
{
ContainerLocator.ResetContainer();
var container = Setup.CreateContainer();
ContainerLocator.SetContainerExtension(Setup.Extension);
Assert.False(ContainerLocator.TrySetContainerExtension(Setup.Extension));

var ex = Record.Exception(() => container.Resolve<ConstructorArgumentViewModel>());

Expand Down
6 changes: 3 additions & 3 deletions tests/Prism.Core.Tests/Ioc/ContainerLocatorFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ContainerLocatorFixture
public void FactoryCreatesContainerExtension()
{
Prism.Ioc.ContainerLocator.ResetContainer();
Assert.Null(Prism.Ioc.ContainerLocator.Current);
Assert.Throws<InvalidOperationException>(() => Prism.Ioc.ContainerLocator.Current);
Prism.Ioc.ContainerLocator.SetContainerExtension(new Mock<IContainerExtension>().Object);
Assert.NotNull(Prism.Ioc.ContainerLocator.Current);
}
Expand All @@ -28,11 +28,11 @@ public void FactoryCreatesContainerExtension()
public void ResetNullsCurrentContainer()
{
Prism.Ioc.ContainerLocator.ResetContainer();
Assert.Null(Prism.Ioc.ContainerLocator.Current);
Assert.Throws<InvalidOperationException>(() => Prism.Ioc.ContainerLocator.Current);
Prism.Ioc.ContainerLocator.SetContainerExtension(new Mock<IContainerExtension>().Object);
Assert.NotNull(Prism.Ioc.ContainerLocator.Current);
Prism.Ioc.ContainerLocator.ResetContainer();
Assert.Null(Prism.Ioc.ContainerLocator.Current);
Assert.Throws<InvalidOperationException>(() => Prism.Ioc.ContainerLocator.Current);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Moq;
using Prism.Container.Wpf.Mocks;
using Prism.Events;
Expand Down Expand Up @@ -154,7 +155,7 @@ public void RunShouldCallRegisterTypes()
public void SetsContainerLocatorCurrentContainer()
{
ContainerLocator.ResetContainer();
Assert.Null(ContainerLocator.Container);
Assert.Throws<InvalidOperationException>(() => ContainerLocator.Container);
var bootstrapper = new MockBootstrapper();

bootstrapper.Run();
Expand Down

0 comments on commit 5c4867c

Please sign in to comment.