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

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

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

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

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            logicExecutor.TranslationDelete(translationMock);

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

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            var exception = Assert.Throws <ArgumentNullException>(() => logicExecutor.TranslationDelete(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 TestThatTranslationDeleteReturnsIdentifierFromServiceReceiptResponse()
        {
            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 <TranslationDeleteCommand, ServiceReceiptResponse>(Arg <TranslationDeleteCommand> .Is.Anything))
            .Return(serviceReceipt)
            .Repeat.Any();

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            var result = logicExecutor.TranslationDelete(translationMock);

            Assert.That(result, Is.EqualTo(serviceReceipt.Identifier));
        }
コード例 #4
0
        public void TestThatTranslationDeleteThrowsIntranetSystemExceptionWhenIdentifierOnTranslationIsNull()
        {
            var commandBusMock = MockRepository.GenerateMock <ICommandBus>();

            var translationMock = MockRepository.GenerateMock <ITranslation>();

            translationMock.Stub(m => m.Identifier)
            .Return(null)
            .Repeat.Any();

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            var exception = Assert.Throws <IntranetSystemException>(() => logicExecutor.TranslationDelete(translationMock));

            Assert.That(exception, Is.Not.Null);
            Assert.That(exception.Message, Is.Not.Null);
            Assert.That(exception.Message, Is.Not.Empty);
            Assert.That(exception.Message, Is.EqualTo(Resource.GetExceptionMessage(ExceptionMessage.IllegalValue, translationMock.Identifier, "Identifier")));
            Assert.That(exception.InnerException, Is.Null);
        }