public TestsBase() { transactionScopeProvider.Setup(x => x.CreateTransactionScope()) .Returns(Mock.Of <ITransactionScope>()); transactionScopeProvider.Setup(x => x.CreateNewTransactionScope(It.IsAny <IsolationLevel>(), It.IsAny <TimeSpan?>())) .Returns(Mock.Of <ITransactionScope>()); mockResolver = new MockDependencyResolver(); mockResolver.AddMock(transactionScopeProvider); mockResolver.AddMock <IBattleService>(); mockResolver.AddMock <ICompanyService>(); DependencyResolver.SetResolver(mockResolver); }
public void ShouldSetTheDependencyResolverSoItCanBeUsedInContext() { // Arrange var di = new MockDependencyResolver(); // Act Context.Initialize.SetDependencyResolver(di); // Assert Context.Resolve <DciContext>().Should().Be.Null(); Context.ResolveAll <DciContext>().Count().Should().Equal(0); Context.Resolve <string>().Should().Equal("MockString"); Context.ResolveAll <string>().Should().Equal(new[] { "MockString", "AnotherMockString" }); Context.Resolve(typeof(string)).Should().Equal("MockString"); Context.ResolveAll(typeof(string)).Should().Equal(new[] { "MockString", "AnotherMockString" }); }
/// <summary> /// Starts the <see cref="IDependencyResolver"/>. /// </summary> protected virtual void StartDependencyResolver() { MockDependencyResolver.Start(); }
static MockDependencyResolver() { Current = new MockDependencyResolver(); }
public AnotherResolver() { _innerResolver = new MockDependencyResolver(); }
public void ShouldSetTheDependencyResolverSoItCanBeUsedInContext() { // Arrange var di = new MockDependencyResolver(); // Act Context.Initialize.SetDependencyResolver(di); // Assert Context.Resolve<DciContext>().Should().Be.Null(); Context.ResolveAll<DciContext>().Count().Should().Equal(0); Context.Resolve<string>().Should().Equal("MockString"); Context.ResolveAll<string>().Should().Equal(new[] { "MockString", "AnotherMockString" }); Context.Resolve(typeof(string)).Should().Equal("MockString"); Context.ResolveAll(typeof(string)).Should().Equal(new[] { "MockString", "AnotherMockString" }); }
public AnotherResolver() { _innerResolver = new MockDependencyResolver(); }