Exemplo n.º 1
0
		public void Setup()
		{

			_testCommand = A.Fake<ICommand>();
			_publisher = A.Fake<IPublisher>();
			_compositeApp = A.Fake<ICompositeApp>();
			_registry = A.Fake<ICommandRegistry>();
			_formatter = A.Fake<IResponseFormatter>();
			_publicationRecord = A.Fake<ICommandPublicationRecord>();
			_jsonSerializer = new DefaultJsonSerializer();
			_xmlSerializer = new DefaultXmlSerializer();

			A.CallTo(() => _testCommand.Created).Returns(DateTime.MaxValue);
			A.CallTo(() => _testCommand.CreatedBy).Returns(new Guid("ba5f18dc-e287-4d9e-ae71-c6989b10d778"));
			A.CallTo(() => _testCommand.Identifier).Returns(new Guid("ba5f18dc-e287-4d9e-ae71-c6989b10d778"));
			A.CallTo(() => _formatter.Serializers).Returns(new List<ISerializer> { _jsonSerializer, _xmlSerializer });
			A.CallTo(() => _publicationRecord.Dispatched).Returns(true);
			A.CallTo(() => _publicationRecord.Error).Returns(false);
			A.CallTo(() => _publicationRecord.Completed).Returns(true);
			A.CallTo(() => _publicationRecord.Created).Returns(DateTime.MinValue);
			A.CallTo(() => _publicationRecord.MessageLocation).Returns(new Uri("http://localhost/fake/message"));
			A.CallTo(() => _publicationRecord.MessageType).Returns(typeof(IPublicationRecord));
			A.CallTo(() => _publicationRecord.CreatedBy).Returns(Guid.Empty);
			A.CallTo(() => _compositeApp.GetCommandForInputModel(A.Dummy<IInputModel>())).Returns(_testCommand);
			A.CallTo(() => _publisher.PublishMessage(A.Fake<ICommand>())).Returns(_publicationId);
			A.CallTo(() => _registry.GetPublicationRecord(_publicationId)).Returns(_publicationRecord);

			_euclidApi = new ApiModule(_compositeApp, _registry, _publisher);
		}
Exemplo n.º 2
0
        public CommandCompleteOrPendingResult(ICommandPublicationRecord record)
        {
            Created         = record.Created;
            Id              = record.Id;
            Status          = record.Status;
            Updated         = record.Updated;
            CommandName     = record.PortableCommand.ClrTypeName;
            QueryReferences = record.QueryReferences;

            Links = new List <JsonLink>()
            {
                new JsonLink(string.Format("/api/commands/publication-registry/{0}", Id), "details"),
                new JsonLink("/api/commands/", "home")
            };

            foreach (var reference in QueryReferences)
            {
                var queryUrl = string.Format("/api/queries/{0}/results?id={1}",
                                             reference.QueryName, reference.QueryParameter);

                Links.Add(new JsonLink(queryUrl, "query-reference"));
            }
        }
Exemplo n.º 3
0
        public DetailedPublicationRecordResult(ICommandPublicationRecord record)
        {
            Created     = record.Created;
            Id          = record.Id;
            Status      = record.Status;
            Updated     = record.Updated;
            CommandName = record.PortableCommand.ClrTypeName;
            Links       = new List <JsonLink>()
            {
                new JsonLink("/api/commands/", "home")
            };
            OriginalCommand = JsonConvert.DeserializeObject(record.PortableCommand.CommandJson);
            CommandSchema   = JsonConvert.DeserializeObject(record.PortableCommand.CommandJsonSchema);
            ErrorDetails    = record.ErrorDetails;
            ErrorHeadline   = record.ErrorHeadline;

            foreach (var reference in record.QueryReferences)
            {
                var queryUrl = string.Format("/api/queries/{0}/results?id={1}",
                                             reference.QueryName, reference.QueryParameter);

                Links.Add(new JsonLink(queryUrl, "query-reference"));
            }
        }
Exemplo n.º 4
0
 public CommandFailedResult(ICommandPublicationRecord record) : base(record)
 {
     ErrorDetails  = record.ErrorDetails;
     ErrorHeadline = record.ErrorHeadline;
 }