public When_the_submissions_service_is_asked_to_send_an_LRAP1_package()
        {
            _applicationId = "01234567890";
            _username = "******";
            _password = "******";

            _fakeCommandInvoker = A.Fake<ICommandInvoker>();

            var attachments = new List<Lrap1Attachment>
            {
                new Lrap1Attachment() {Payload = "Attachment 1 payload data"},
                new Lrap1Attachment() {Payload = "Attachment 2 payload data"}
            };

            _package = new Lrap1Package()
            {
                Payload = "Lrap1 Payload Data",
                Attachments = attachments
            };

            A.CallTo(
                () =>
                    _fakeCommandInvoker.Execute<CreateLrap1SubmissionCommand, CreateLrap1SubmissionQueryResult>(
                        A<CreateLrap1SubmissionCommand>.Ignored)).Returns(new CreateLrap1SubmissionQueryResult()
                        {
                            Command = new CreateLrap1SubmissionCommand()
                                {
                                    ApplicationId = _applicationId,
                                    Username = _username,
                                    Payload = _package.Payload
                                }
                        });

            A.CallTo(
                () =>
                    _fakeCommandInvoker.Execute<CreateLrap1AttachmentCommand, CreateLrap1AttachmentQueryResult>(
                        A<CreateLrap1AttachmentCommand>.Ignored)).Returns(new CreateLrap1AttachmentQueryResult()
                        {
                            Command = new CreateLrap1AttachmentCommand()
                            {
                                AttachmentId = "98765",
                                ApplicationId = _applicationId,
                                Username = _username,
                                Payload = _package.Payload
                            }
                        });

            _fakeMessageSender = A.Fake<ISendMessages>();

            A.CallTo(() => _fakeMessageSender.Send(A<SubmitLrap1Command>.That.Matches(
                c => c.Username == _username &&
                     c.Password == _password &&
                     c.Payload == _package.Payload)))
                .Returns(new SubmitLrap1Result()
                    {
                        Command = new SubmitLrap1Command()
                        {
                            ApplicationId = _applicationId,
                            Username = _username,
                            Password = _password,
                            Payload = _package.Payload
                        }
                    });

            var sut = new Lrap1SubmissionService(_fakeMessageSender, _fakeCommandInvoker);
            _response = sut.Submit(_username, _password, _package);
        }
Esempio n. 2
0
        public When_the_submissions_service_is_asked_to_send_an_LRAP1_package()
        {
            _applicationId = "01234567890";
            _username      = "******";
            _password      = "******";

            _fakeCommandInvoker = A.Fake <ICommandInvoker>();

            var attachments = new List <Lrap1Attachment>
            {
                new Lrap1Attachment()
                {
                    Payload = "Attachment 1 payload data"
                },
                new Lrap1Attachment()
                {
                    Payload = "Attachment 2 payload data"
                }
            };

            _package = new Lrap1Package()
            {
                Payload     = "Lrap1 Payload Data",
                Attachments = attachments
            };

            A.CallTo(
                () =>
                _fakeCommandInvoker.Execute <CreateLrap1SubmissionCommand, CreateLrap1SubmissionQueryResult>(
                    A <CreateLrap1SubmissionCommand> .Ignored)).Returns(new CreateLrap1SubmissionQueryResult()
            {
                Command = new CreateLrap1SubmissionCommand()
                {
                    ApplicationId = _applicationId,
                    Username      = _username,
                    Payload       = _package.Payload
                }
            });

            A.CallTo(
                () =>
                _fakeCommandInvoker.Execute <CreateLrap1AttachmentCommand, CreateLrap1AttachmentQueryResult>(
                    A <CreateLrap1AttachmentCommand> .Ignored)).Returns(new CreateLrap1AttachmentQueryResult()
            {
                Command = new CreateLrap1AttachmentCommand()
                {
                    AttachmentId  = "98765",
                    ApplicationId = _applicationId,
                    Username      = _username,
                    Payload       = _package.Payload
                }
            });

            _fakeMessageSender = A.Fake <ISendMessages>();

            A.CallTo(() => _fakeMessageSender.Send(A <SubmitLrap1Command> .That.Matches(
                                                       c => c.Username == _username &&
                                                       c.Password == _password &&
                                                       c.Payload == _package.Payload)))
            .Returns(new SubmitLrap1Result()
            {
                Command = new SubmitLrap1Command()
                {
                    ApplicationId = _applicationId,
                    Username      = _username,
                    Password      = _password,
                    Payload       = _package.Payload
                }
            });

            var sut = new Lrap1SubmissionService(_fakeMessageSender, _fakeCommandInvoker);

            _response = sut.Submit(_username, _password, _package);
        }