Exemple #1
0
        public void TestThatHouseholdMemberAddCallsPublishOnCommandBus()
        {
            var fixture = new Fixture();

            var mailAddress = fixture.Create <string>();
            var translationInfoIdentifier = Guid.NewGuid();

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

            commandBusMock.Stub(m => m.Publish <HouseholdMemberAddCommand, ServiceReceiptResponse>(Arg <HouseholdMemberAddCommand> .Is.NotNull))
            .WhenCalled(e =>
            {
                var command = (HouseholdMemberAddCommand)e.Arguments.ElementAt(0);
                Assert.That(command.MailAddress, Is.Not.Null);
                Assert.That(command.MailAddress, Is.Not.Empty);
                Assert.That(command.MailAddress, Is.EqualTo(mailAddress));
                Assert.That(command.TranslationInfoIdentifier, Is.EqualTo(translationInfoIdentifier));
            })
            .Return(fixture.Create <ServiceReceiptResponse>())
            .Repeat.Any();

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            logicExecutor.HouseholdMemberAdd(mailAddress, translationInfoIdentifier);

            commandBusMock.AssertWasCalled(m => m.Publish <HouseholdMemberAddCommand, ServiceReceiptResponse>(Arg <HouseholdMemberAddCommand> .Is.NotNull));
        }
Exemple #2
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));
        }
Exemple #3
0
        public void TestThatForeignKeyModifyCallsPublishOnCommandBus()
        {
            var fixture = new Fixture();

            var foodGroupMock = DomainObjectMockBuilder.BuildFoodGroupMock();
            // ReSharper disable PossibleInvalidOperationException
            var foreignKeyMock = DomainObjectMockBuilder.BuildForeignKeyMock(foodGroupMock.Identifier.Value, foodGroupMock.GetType());
            // ReSharper restore PossibleInvalidOperationException

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

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

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            logicExecutor.ForeignKeyModify(foreignKeyMock);

            commandBusMock.AssertWasCalled(m => m.Publish <ForeignKeyModifyCommand, ServiceReceiptResponse>(Arg <ForeignKeyModifyCommand> .Is.NotNull));
        }
Exemple #4
0
        public void TestThatConstructorInitializeLogicExecutor()
        {
            var commandBusMock = MockRepository.GenerateMock <ICommandBus>();

            var logicExecutor = new LogicExecutor(commandBusMock);

            Assert.That(logicExecutor, Is.Not.Null);
        }
        public static void execute(LogicExecutor executor)
        {
            executor(_instance);

            LogicUpdateHandler[] hArr = new LogicUpdateHandler[_updateHandlers.Count];
            _updateHandlers.CopyTo(hArr);
            foreach (var handler in hArr)
            {
                App.Current.Dispatcher.Invoke(() =>
                {
                    handler(_instance);
                });
            }
        }
Exemple #6
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);
        }
Exemple #7
0
        public void TestThatForeignKeyModifyThrowsArgumentNullExceptionWhenForeignKeyIsNull()
        {
            var commandBusMock = MockRepository.GenerateMock <ICommandBus>();

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            var exception = Assert.Throws <ArgumentNullException>(() => logicExecutor.ForeignKeyModify(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("foreignKey"));
            Assert.That(exception.InnerException, Is.Null);
        }
Exemple #8
0
        public void TestThatHouseholdMemberAddReturnsIdentifierFromServiceReceiptResponse()
        {
            var fixture = new Fixture();

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

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

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            var result = logicExecutor.HouseholdMemberAdd(fixture.Create <string>(), Guid.NewGuid());

            Assert.That(result, Is.EqualTo(serviceReceipt.Identifier));
        }
Exemple #9
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));
        }
Exemple #10
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);
        }
Exemple #11
0
        public void TestThatForeignKeyDeleteReturnsIdentifierFromServiceReceiptResponse()
        {
            var fixture = new Fixture();

            var foodGroupMock = DomainObjectMockBuilder.BuildFoodGroupMock();
            // ReSharper disable PossibleInvalidOperationException
            var foreignKeyMock = DomainObjectMockBuilder.BuildForeignKeyMock(foodGroupMock.Identifier.Value, foodGroupMock.GetType());
            // ReSharper restore PossibleInvalidOperationException

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

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

            var logicExecutor = new LogicExecutor(commandBusMock);

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

            var result = logicExecutor.ForeignKeyDelete(foreignKeyMock);

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