Пример #1
0
        public void Pipeline_ReturnsRequestedType_IfParticipantsDoNotCare()
        {
            var reflectionService = GetReflectionService(t => { });
            var type = ReflectionObjectMother.GetSomeNonSubclassableType();

            var result = reflectionService.GetAssembledType(type);

            Assert.That(result, Is.SameAs(type));
        }
Пример #2
0
        public void Participant_MayReportError()
        {
            var exception         = new Exception();
            var reflectionService = GetReflectionService(t => { throw exception; });
            var type = ReflectionObjectMother.GetSomeNonSubclassableType();

            TestDelegate action = () => reflectionService.GetAssembledType(type);

            Assert.That(action, Throws.Exception.SameAs(exception));
        }
Пример #3
0
        public void AssembleType_NonSubclassableType_LetParticipantReportErrors_AndReturnsRequestedType()
        {
            var participantMock     = new Mock <IParticipant>();
            var typeAssembler       = CreateTypeAssembler(participants: new[] { participantMock.Object });
            var nonSubclassableType = ReflectionObjectMother.GetSomeNonSubclassableType();
            var typeID            = AssembledTypeIDObjectMother.Create(nonSubclassableType);
            var codeGeneratorStub = new Mock <IMutableTypeBatchCodeGenerator>();

            var result = typeAssembler.AssembleType(typeID, _participantStateMock.Object, codeGeneratorStub.Object);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Type, Is.SameAs(nonSubclassableType));
            participantMock.Verify(mock => mock.HandleNonSubclassableType(nonSubclassableType), Times.Once());
            participantMock.Verify(mock => mock.Participate(null, It.IsAny <IProxyTypeAssemblyContext>()), Times.Never());
        }
Пример #4
0
        public void AssembleType_NonSubclassableType_LetParticipantReportErrors_AndReturnsRequestedType()
        {
            var participantMock     = MockRepository.GenerateMock <IParticipant>();
            var typeAssembler       = CreateTypeAssembler(participants: new[] { participantMock });
            var nonSubclassableType = ReflectionObjectMother.GetSomeNonSubclassableType();
            var typeID            = AssembledTypeIDObjectMother.Create(nonSubclassableType);
            var codeGeneratorStub = MockRepository.GenerateStub <IMutableTypeBatchCodeGenerator>();

            var result = typeAssembler.AssembleType(typeID, _participantStateMock, codeGeneratorStub);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Type, Is.SameAs(nonSubclassableType));
            participantMock.AssertWasCalled(mock => mock.HandleNonSubclassableType(nonSubclassableType));
            participantMock.AssertWasNotCalled(mock => mock.Participate(Arg.Is <object> (null), Arg <IProxyTypeAssemblyContext> .Is.Anything));
        }