示例#1
0
        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);
        }
示例#2
0
            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" });
            }
示例#3
0
 /// <summary>
 /// Starts the <see cref="IDependencyResolver"/>.
 /// </summary>
 protected virtual void StartDependencyResolver()
 {
     MockDependencyResolver.Start();
 }
示例#4
0
 static MockDependencyResolver()
 {
     Current = new MockDependencyResolver();
 }
示例#5
0
 public AnotherResolver()
 {
     _innerResolver = new MockDependencyResolver();
 }
示例#6
0
            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" });
            }
示例#7
0
 public AnotherResolver()
 {
     _innerResolver = new MockDependencyResolver();
 }