コード例 #1
0
        public void TestThatTranslationAddCallsPublishOnCommandBus()
        {
            var fixture = new Fixture();

            var translationMock = DomainObjectMockBuilder.BuildTranslationMock(Guid.NewGuid());

            var commandBusMock = MockRepository.GenerateMock <ICommandBus>();

            commandBusMock.Stub(m => m.Publish <TranslationAddCommand, ServiceReceiptResponse>(Arg <TranslationAddCommand> .Is.NotNull))
            .WhenCalled(e =>
            {
                var command = (TranslationAddCommand)e.Arguments.ElementAt(0);
                // ReSharper disable PossibleInvalidOperationException
                Assert.That(command.TranslationInfoIdentifier, Is.EqualTo(translationMock.TranslationInfo.Identifier.Value));
                // ReSharper restore PossibleInvalidOperationException
                Assert.That(command.TranslationOfIdentifier, Is.EqualTo(translationMock.TranslationOfIdentifier));
                Assert.That(command.TranslationValue, Is.Not.Null);
                Assert.That(command.TranslationValue, Is.Not.Empty);
                Assert.That(command.TranslationValue, Is.EqualTo(translationMock.Value));
            })
            .Return(fixture.Create <ServiceReceiptResponse>())
            .Repeat.Any();

            var logicExecutor = new LogicExecutor(commandBusMock);

            Assert.That(logicExecutor, Is.Not.Null);

            logicExecutor.TranslationAdd(translationMock);

            commandBusMock.AssertWasCalled(m => m.Publish <TranslationAddCommand, ServiceReceiptResponse>(Arg <TranslationAddCommand> .Is.NotNull));
        }
コード例 #2
0
        public void TestThatTranslationAddThrowsArgumentNullExceptionWhenTranslationIsNull()
        {
            var commandBusMock = MockRepository.GenerateMock <ICommandBus>();

            var logicExecutor = new LogicExecutor(commandBusMock);

            Assert.That(logicExecutor, Is.Not.Null);

            var exception = Assert.Throws <ArgumentNullException>(() => logicExecutor.TranslationAdd(null));

            Assert.That(exception, Is.Not.Null);
            Assert.That(exception.ParamName, Is.Not.Null);
            Assert.That(exception.ParamName, Is.Not.Empty);
            Assert.That(exception.ParamName, Is.EqualTo("translation"));
            Assert.That(exception.InnerException, Is.Null);
        }
コード例 #3
0
        public void TestThatTranslationAddReturnsIdentifierFromServiceReceiptResponse()
        {
            var fixture = new Fixture();

            var translationMock = DomainObjectMockBuilder.BuildTranslationMock(Guid.NewGuid());

            var serviceReceipt = fixture.Create <ServiceReceiptResponse>();
            var commandBusMock = MockRepository.GenerateMock <ICommandBus>();

            commandBusMock.Stub(m => m.Publish <TranslationAddCommand, ServiceReceiptResponse>(Arg <TranslationAddCommand> .Is.Anything))
            .Return(serviceReceipt)
            .Repeat.Any();

            var logicExecutor = new LogicExecutor(commandBusMock);

            Assert.That(logicExecutor, Is.Not.Null);

            var result = logicExecutor.TranslationAdd(translationMock);

            Assert.That(result, Is.EqualTo(serviceReceipt.Identifier));
        }