Beispiel #1
0
        public static ITestCommand CreateCommand(IMethodInfo methodInfo, ConstructorInfo constructor, MockSettings settings, MockSettings constructorSettings)
        {
            var requestProvider = new RequestProvider();
              var reflectionHelper = new ReflectionHelper();
              var mockRepository = new MoqMockRepository (reflectionHelper);
              var constructorChooser = new CompositeConstructorChooser (s_constructorChoosers);
              var resolver = new Resolver (mockRepository, constructorChooser, reflectionHelper);
              var moqResolver = new MoqResolver (resolver);

              return new NukitoFactCommand (methodInfo, constructor, requestProvider, moqResolver, reflectionHelper, mockRepository, settings, constructorSettings);
        }
Beispiel #2
0
        public void GetSelfBindableConcreteClass(Mock<ICreator> collaborator, MoqResolver mockRepository)
        {
            // Arrange
              var a = new A();
              collaborator.Setup(c => c.GetOrCreate(typeof (A), _context)).Returns(a);

              // Act
              object result = mockRepository.Get(typeof (A), _context);

              // Assert
              result.Should().BeSameAs(a);
        }
Beispiel #3
0
        public void GetMockType(Mock<ICreator> collaborator, MoqResolver mockRepository)
        {
            // Arrange
              var mock = new Mock<IA>();
              collaborator.Setup(c => c.GetOrCreate(typeof (IA), _context)).Returns(mock.Object);

              // Act
              object result = mockRepository.Get(typeof (Mock<IA>), _context);

              // Assert
              result.Should().BeSameAs(mock);
        }
Beispiel #4
0
        public void GetReturnsInnerValue(MoqResolver moqResolver, Mock<IResolver> innerResolver)
        {
            // Arrange
              var request = new Request (typeof (string), false, new MockSettings(), new Dictionary<Type, object>());
              var fakeInnerValue = new object();
              innerResolver.Setup(x => x.Get (request)).Returns (fakeInnerValue);

              // Act
              var result = moqResolver.Get (request);

              // Assert
              result.Should().BeSameAs (fakeInnerValue);
        }
Beispiel #5
0
        public void GetRetrievesConfigFromInnerValue(MoqResolver moqResolver, Mock<IResolver> innerResolver, MockSettings settings)
        {
            // Arrange
              var instances = new Dictionary<Type, object>();
              var fakeInnerValue = new Mock<IMocked>();
              innerResolver
              .Setup (x => x.Get (It.Is ((Request r) => r.Type == typeof (string) && r.ForceMockCreation && r.Settings == settings && r.Instances == instances)))
              .Returns (fakeInnerValue.Object);

              // Act
              var result = moqResolver.Get (new Request (typeof (Mock<string>), false, settings, instances));

              // Assert
              result.Should ().BeSameAs (fakeInnerValue);
        }