public void MicrosoftDependencyResolver_Should_Throw_If_Attempt_Registration_After_Build() { var wrapper = new ContainerWrapper(); wrapper.BuildAndUse(); var result = Record.Exception(() => Locator.CurrentMutable.Register(() => new ViewOne())); result.ShouldBeOfType <InvalidOperationException>(); }
public void MicrosoftDependencyResolver_Should_Throw_If_ServiceRegistionCallback_Called() { var wrapper = new ContainerWrapper(); wrapper.BuildAndUse(); var result = Record.Exception(() => Locator.CurrentMutable.ServiceRegistrationCallback(typeof(IScreen), disposable => { })); result.ShouldBeOfType <NotImplementedException>(); }
public void MicrosoftDependencyResolver_Should_Resolve_Screen() { var wrapper = new ContainerWrapper(); var services = wrapper.ServiceCollection; services.AddSingleton <IScreen>(new MockScreen()); wrapper.BuildAndUse(); var screen = Locator.Current.GetService <IScreen>(); screen.ShouldNotBeNull(); screen.ShouldBeOfType <MockScreen>(); }
public void MicrosoftDependencyResolver_Should_Resolve_Named_View() { var wrapper = new ContainerWrapper(); var services = wrapper.ServiceCollection; services.AddTransient <IViewFor <ViewModelTwo>, ViewTwo>(); wrapper.BuildAndUse(); var viewTwo = Locator.Current.GetService(typeof(IViewFor <ViewModelTwo>)); viewTwo.ShouldNotBeNull(); viewTwo.ShouldBeOfType <ViewTwo>(); }
public void MicrosoftDependencyResolver_Should_Resolve_View_Models() { var wrapper = new ContainerWrapper(); var services = wrapper.ServiceCollection; services.AddTransient <ViewModelOne>(); services.AddTransient <ViewModelTwo>(); wrapper.BuildAndUse(); var vmOne = Locator.Current.GetService <ViewModelOne>(); var vmTwo = Locator.Current.GetService <ViewModelTwo>(); vmOne.ShouldNotBeNull(); vmTwo.ShouldNotBeNull(); }
public void MicrosoftDependencyResolver_Should_UnregisterAll() { var wrapper = new ContainerWrapper(); var services = wrapper.ServiceCollection; services.AddSingleton <IScreen>(new MockScreen()); Locator.CurrentMutable.HasRegistration(typeof(IScreen)) .ShouldBeTrue(); Locator.CurrentMutable.UnregisterAll(typeof(IScreen)); var result = Locator.Current.GetService <IScreen>(); result.ShouldBeNull(); }