Exemplo n.º 1
0
        /// <summary>
        /// Gets message text
        /// </summary>
        /// <param name="number">Message number</param>
        /// <returns>Message text or empty</returns>
        internal static string GetMessageText(MessageNumber number)
        {
            var sres = string.Empty;

            messagesString.TryGetValue(number, out sres);
            if (!string.IsNullOrEmpty(sres))
            {
                return(Properties.Resources.ResourceManager.GetString(sres, Properties.Resources.Culture));
            }

            if ((number & MessageNumber.Information) != 0)
            {
                return(res.GeneralInformation);
            }
            else if ((number & MessageNumber.Warning) != 0)
            {
                return(res.GeneralWarning);
            }
            else if ((number & MessageNumber.Error) != 0)
            {
                return(res.GeneralError);
            }
            else if ((number & MessageNumber.Reserved) != 0)
            {
                return(res.Reserved);
            }
            else
            {
                Debug.Assert(false, "No text assigned for the message number", "Number {0}", number);
                return(string.Empty);
            }
        }
Exemplo n.º 2
0
        private void processStream(Stream stream)
        {
            MessageStream msgStream = new MessageStream(new StandardStream(stream));

            Message msg = msgStream.readMessage();

            if (msg == null)
            {
                return;
            }

            EMessageType mType = (EMessageType)msg.getType();

            if (mType == EMessageType.eNumber)
            {
                // End a session
                MessageNumber response = new MessageNumber(msg);
                int           sid      = response.getNumber();
                m_agent.signalToStopSession(sid);
            }
            else if (mType == EMessageType.ePidAndCompileRequest)
            {
                MessagePidAndCompileRequest request = new MessagePidAndCompileRequest(msg);
                TCompileResult cr = m_agent.compile(request.getPid(), request.getCmd(), request.getWorkingDir());

                // The output file was already saved to local disk by the agent, now respond the result only
                msg = MessageCompileResponse.createMessage(cr.wasExec, cr.exitCode, cr.outputText, null, 0);
                msgStream.writeMessage(msg);
            }
            else
            {
                // WTF???
            }
        }
Exemplo n.º 3
0
        protected void UpdateProcessStatus(MessageNumber convId, bool alive)
        {
            if (PendingHeartbeatReplies.ContainsKey(convId))
            {
                int processId = PendingHeartbeatReplies[convId];
                PendingHeartbeatReplies.Remove(convId);

                if (!alive && KnownClients.ContainsKey(processId))
                {
                    Logger.Info("Process " + processId + " is not responding, removing from current connections");
                    ProcessInfo process = KnownClients[processId];
                    process.Status = ProcessInfo.StatusCode.Terminated;
                    process.HeartbeatTimer.Stop();
                    KillProcessConversation conv = new KillProcessConversation(process.ProcessId, process.EndPoint);
                    conv.Start();
                }
                else
                {
                    Logger.Info("Process " + processId.ToString() + " is still responding");
                }
            }
            else
            {
                Logger.Error("Received unexpected response from heatbeat conversation");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creating message
        /// </summary>
        /// <param name="number">Number of the message</param>
        /// <param name="description">Description of the message</param>
        /// <param name="openObject">Affected object</param>
        /// <param name="propertyName">Affected property</param>
        /// <param name="innerMessage">Inner message</param>
        /// <returns>The created message or null if the number is not supported</returns>
        public static OpenMessage Create(MessageNumber number, OpenObject openObject, string propertyName, string description, OpenMessage innerMessage = null)
        {
            OpenMessage msg = null;

            if ((number & MessageNumber.Information) != 0)
            {
                msg = new InformationMessage(number, openObject, propertyName, description, innerMessage);
            }
            else if ((number & MessageNumber.Warning) != 0)
            {
                msg = new WarningMessage(number, openObject, propertyName, description, innerMessage);
            }
            else if ((number & MessageNumber.Error) != 0)
            {
                msg = new ErrorMessage(number, openObject, propertyName, description, innerMessage);
            }
            else if ((number & MessageNumber.Reserved) != 0)
            {
                Debug.Assert(false, "Not supported message", "Number {0}", number);
            }
            else
            {
                Debug.Assert(false, "Not supported message", "Number {0}", number);
            }

            return(msg);
        }
Exemplo n.º 5
0
        private void signalToStopCompiling()
        {
            if (m_sid == 0)
            {
                return;
            }
            // Connect to the agent and send signal to stop
            NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", Config.s_kAgentName);

            try
            {
                pipeClient.Connect(s_kPipeConnectTimeout);
            }
            catch (Exception)
            {
                return;
            }
            MessageStream stream = new MessageStream(new StandardStream(pipeClient));
            Message       msg    = MessageNumber.createMessage(m_sid);

            if (!stream.writeMessage(msg))
            {
                CConsole.writeError("error: could not send data to the mongcc agent.\n");
            }
            pipeClient.Close();
        }
Exemplo n.º 6
0
 public EnvelopeQueue GetByConversationId(MessageNumber convId)
 {
     EnvelopeQueue queue = null;
     if(convId != null)
         dictionary.TryGetValue(convId, out queue);
     return queue;
 }
Exemplo n.º 7
0
 public ServerMessage(byte[] bytes)
 {
     MessageNumber = bytes.FirstOrDefault();
     Bytes         = bytes.RemoveAt(0);
     Type          = MessageNumber.GetMessageType();
     RawText       = Encoding.Default.GetString(Bytes);
 }
Exemplo n.º 8
0
        public Task <IList <object> > GetEventsAfterAsync(string resourceName, MessageNumber lastMessageNumber)
        {
            var events = (_newApiEvents.GetValueOrDefault(resourceName) ?? new List <object>())
                         .Skip(lastMessageNumber == MessageNumber.NotSet ? 0 : lastMessageNumber.Value + 1)
                         .ToList();

            return(Task.FromResult((IList <object>)events));
        }
Exemplo n.º 9
0
 public void CloseQueue(MessageNumber queueId)
 {
     if (queueId != null)
     {
         EnvelopeQueue queue = null;
         dictionary.TryRemove(queueId, out queue);
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="number">Number of the message</param>
 /// <param name="description">Description of the message</param>
 /// <param name="openObject">Affected object</param>
 /// <param name="propertyName">Affected property</param>
 /// <param name="innerMessage">Inner message</param>
 internal OpenMessage(MessageNumber number, OpenObject openObject, string propertyName, string description, OpenMessage innerMessage = null)
 {
     Number       = number;
     InnerMessage = innerMessage;
     Description  = description;
     Object       = openObject;
     PropertyName = propertyName;
 }
Exemplo n.º 11
0
        private void handleMessageFreeNum()
        {
            int num = m_server.getFreeHandlerNumber();

            CConsole.writeInfoLine(string.Format("{0} Recv free num request, send response = {1}", cur(), num));
            Message msg = MessageNumber.createMessage(num);

            m_messageStream.writeMessage(msg);
        }
Exemplo n.º 12
0
 public ContractManager() : base("Contract Manager")
 {
     MessageNumber.SetSeqNumber(4923);
     MyProcessInfo.Type         = ProcessInfo.ProcessType.ContractManager;
     MyProcessInfo.Status       = ProcessInfo.StatusCode.NotInitialized;
     MyProcessInfo.AliveRetries = 5;
     MyProcessInfo.EndPoint     = LocalEndpoint;
     MyProcessInfo.Label        = "Contract Manager";
     ConversationManager.RegisterNewConversationTypes(GetValidConversations());
 }
Exemplo n.º 13
0
            public MessageNumberRange(MessageNumber start, int batchSize)
            {
                if (start == MessageNumber.NotSet)
                {
                    throw new InvalidMessageNumberRangeException("Range cannot start with NotSet value");
                }

                Start = start;
                End   = MessageNumber.New(start.Value + batchSize - 1);
            }
Exemplo n.º 14
0
 public Conversation(string name, NetworkClient communicator, MessageNumber convId = null) : base(name)
 {
     Id           = convId ?? MessageNumber.Create();
     Properties   = SharedProperties.Instance;
     Communicator = communicator;
     Communicator.OnMessageReceived += new NetworkClient.MessageReceived(ReceiveDirectMessage);
     MessageInbox         = new ConcurrentQueue <Envelope>();
     SentMessages         = new ConcurrentQueue <Envelope>();
     ReceivedMessages     = new ConcurrentDictionary <Message, IPEndPoint>();
     CallbacksRegistered  = false;
     AllowInboundMessages = true;
     WaitingForReply      = true;
 }
Exemplo n.º 15
0
        public Conversation(string name, MessageNumber convId = null) : base(name)
        {
            Id                   = convId ?? MessageNumber.Create();
            Properties           = SharedProperties.Instance;
            Communicator         = ConversationManager.PrimaryCommunicator;
            MessageInbox         = new ConcurrentQueue <Envelope>();
            SentMessages         = new ConcurrentQueue <Envelope>();
            ReceivedMessages     = new ConcurrentDictionary <Message, IPEndPoint>();
            CallbacksRegistered  = false;
            AllowInboundMessages = true;
            WaitingForReply      = true;

            RegisterWithConversationManager();
        }
Exemplo n.º 16
0
 public AuthManager() : base("AuthManager")
 {
     MessageNumber.SetSeqNumber(84);
     HeartbeatIntervalMs        = 30000;
     KnownClients               = new Dictionary <int, ProcessInfo>();
     PendingHeartbeatReplies    = new Dictionary <MessageNumber, int>();
     MyProcessInfo.ProcessId    = 0;
     MyProcessInfo.Type         = ProcessInfo.ProcessType.AuthenticationManager;
     MyProcessInfo.Status       = ProcessInfo.StatusCode.NotInitialized;
     MyProcessInfo.AliveRetries = 5;
     MyProcessInfo.Label        = "Authentication Manager";
     ContractManagerInfo        = null;
     ConversationManager.RegisterNewConversationTypes(GetValidConversations());
 }
Exemplo n.º 17
0
        public EnvelopeQueue CreateQueue(MessageNumber queueId)
        {
            EnvelopeQueue queue = null;

            if (queueId != null)
            {
                dictionary.TryGetValue(queueId, out queue);

                if (queue == null)
                {
                    queue = new EnvelopeQueue() { QueueId = queueId };
                    dictionary.TryAdd(queueId, queue);
                }
            }

            return queue;
        }
Exemplo n.º 18
0
 protected override void ProcessResponse(Envelope envelope)
 {
     if (envelope.Message.GetType() == typeof(AliveRequest))
     {
         AliveReply message = new AliveReply();
         message.ConvId  = Id;
         message.MsgId   = MessageNumber.Create();
         message.Success = true;
         message.Note    = "Ah, ha, ha, ha, stayin' alive, stayin' alive";
         Envelope toSend = new Envelope(envelope.Address, message);
         WaitingForReply = false;
         SendMessage(toSend);
     }
     else
     {
         Logger.Info("Received unexpected message: " + envelope.Message.ToString());
     }
 }
Exemplo n.º 19
0
        public int CompareTo(object obj)
        {
            var ballot = (Ballot)obj;

            var res = Timestamp.CompareTo(ballot.Timestamp);

            if (res != 0)
            {
                return(res);
            }

            res = MessageNumber.CompareTo(ballot.MessageNumber);
            if (res != 0)
            {
                return(res);
            }

            return(StructuralComparisons.StructuralComparer.Compare(Identity, ballot.Identity));
        }
Exemplo n.º 20
0
        public async Task TakeAllEvents_ThereIsNoTrackingForLastEventNumberYet()
        {
            var api = new TestEventApi();

            api.SetupTestResource(
                resourceName: "resource",
                newTestEvents: new List <TestResourceCreatedEvent>
            {
                new TestResourceCreatedEvent
                {
                    Id = new Guid("0683f052-40f0-4bff-879e-f4bea94c0ed0")
                },
                new TestResourceCreatedEvent
                {
                    Id = new Guid("C471D99B-2C72-44F6-898F-F0BABCBAC9D7")
                },
                new TestResourceCreatedEvent
                {
                    Id = new Guid("6843FE44-3029-47D3-A9B9-C21A3BAB4397")
                }
            });

            var eventTrackingRepository = new ListEventTrackingRepository(new List <EventTracking>
            {
                EventTracking.Preset("resource", MessageNumber.New(1))
            });

            var eventMonitor = new EventMonitor(api, eventTrackingRepository);

            var handler = new OnAnyEventRecordInListEventHandler <TestResourceCreatedEvent>();

            eventMonitor.Subscribe <TestResourceCreatedEvent>("resource", handler);

            await eventMonitor.Poll();

            Assert.Equal(1, handler.Events.Count);
            Assert.Equal(new Guid("6843FE44-3029-47D3-A9B9-C21A3BAB4397"), handler.Events[0].Id);

            var lastMessageNumber = await eventTrackingRepository.GetLastMessageNumber("resource");

            Assert.Equal(2, lastMessageNumber.Value);
        }
Exemplo n.º 21
0
        public async Task <IList <object> > GetEventsAfterAsync(string resourceName, MessageNumber lastMessageNumber)
        {
            Console.WriteLine($"GetEventsAfterAsync with Last message number: {lastMessageNumber}");
            var allEvents = new List <object>();

            List <object>      retrievedEventsList;
            MessageNumberRange numberRange;

            if (lastMessageNumber == MessageNumber.NotSet)
            {
                numberRange = new MessageNumberRange(MessageNumber.New(0), _batchSize);

                retrievedEventsList = await GetAsync(resourceName, numberRange);

                allEvents.AddRange(retrievedEventsList);
            }
            else
            {
                var skippedBatches = lastMessageNumber.Value / _batchSize;
                numberRange = new MessageNumberRange(MessageNumber.New(skippedBatches * _batchSize), _batchSize);

                retrievedEventsList = await GetAsync(resourceName, numberRange);

                var skippedBatchSize = lastMessageNumber.Value % _batchSize;
                var eventsListStartingFromLastMessageNumber = retrievedEventsList.Skip(skippedBatchSize + 1).ToList();

                allEvents.AddRange(eventsListStartingFromLastMessageNumber);
            }

            while (retrievedEventsList.Count == _batchSize)
            {
                numberRange         = new MessageNumberRange(MessageNumber.New(numberRange.End.Value + 1), _batchSize);
                retrievedEventsList = await GetAsync(resourceName, numberRange);

                allEvents.AddRange(retrievedEventsList);
            }

            return(allEvents);
        }
Exemplo n.º 22
0
        /// <inheritdoc />
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = ChatId != null?ChatId.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Body != null ? Body.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (SenderName != null ? SenderName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ FromMe.GetHashCode();
                hashCode = (hashCode * 397) ^ (Author != null ? Author.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Time.GetHashCode();
                hashCode = (hashCode * 397) ^ MessageNumber.GetHashCode();
                hashCode = (hashCode * 397) ^ Self.GetHashCode();
                hashCode = (hashCode * 397) ^ IsForwarded.GetHashCode();
                hashCode = (hashCode * 397) ^ (QuotedMessageBody != null ? QuotedMessageBody.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (QuotedMessageId != null ? QuotedMessageId.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (QuotedMessageType != null ? QuotedMessageType.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ChatName != null ? ChatName.GetHashCode() : 0);
                return(hashCode);
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="number">Number of the message</param>
 /// <param name="description">Description of the message</param>
 /// <param name="openObject">Affected object</param>
 /// <param name="propertyName">Affected property</param>
 /// <param name="innerMessage">Inner message</param>
 internal InformationMessage(MessageNumber number, OpenObject openObject, string propertyName, string description, OpenMessage innerMessage = null)
     : base(number, openObject, propertyName, description, innerMessage)
 {
     Debug.Assert((number & MessageNumber.Information) != 0, "No information Message number in Information message");
 }
Exemplo n.º 24
0
 public static OperationResult Build(OperationResultTypes type, object obj, Exception ex, MessageNumber message)
 {
     return(new OperationResult()
     {
         Type = type,
         ReturnObject = obj,
         Message = message
     });
 }
Exemplo n.º 25
0
 public static OperationResult Success(object obj, MessageNumber message)
 {
     return(OperationResult.Build(OperationResultTypes.Success, obj, null, message));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="number">Number of the message</param>
 /// <param name="description">Description of the message</param>
 /// <param name="openObject">Affected object</param>
 /// <param name="propertyName">Affected property</param>
 /// <param name="innerMessage">Inner message</param>
 internal ErrorMessage(MessageNumber number, OpenObject openObject, string propertyName, string description, OpenMessage innerMessage = null)
     : base(number, openObject, propertyName, description, innerMessage)
 {
     Debug.Assert((number & MessageNumber.Error) != 0, "No error Message number in Error message");
 }
Exemplo n.º 27
0
 public static OperationResult Error(object obj, MessageNumber message)
 {
     return(OperationResult.Build(OperationResultTypes.Error, obj, null, message));
 }
Exemplo n.º 28
0
        public static void ProcessOpcodes(Session MySession, ushort MessageTypeOpcode, List <byte> myPacket)
        {
            ///Expected message length
            ushort MessageLength;
            ushort MessageNumber;
            ushort Opcode;

            ///Short message, 1 byte for message length
            if ((MessageTypeOpcode == MessageOpcodeTypes.ShortReliableMessage) || (MessageTypeOpcode == MessageOpcodeTypes.UnknownMessage))
            {
                MessageLength = (ushort)myPacket[0];
                ///Remove read byte
                myPacket.RemoveRange(0, 1);
            }

            ///Long message, 2 bytes for message length
            else
            {
                MessageLength = (ushort)(myPacket[1] << 8 | myPacket[0]);
                ///Remove 2 read bytes
                myPacket.RemoveRange(0, 2);
            }

            ///Make sure Message number is expected, needs to be in order.
            MessageNumber = (ushort)(myPacket[1] << 8 | myPacket[0]);


            if (MySession.clientMessageNumber + 1 == MessageNumber)
            {
                ///Increment for every message read, in order.
                MySession.IncrementClientMessageNumber();

                //If F9 type, no opcode process it seperately.
                if (MessageTypeOpcode == MessageOpcodeTypes.UnknownMessage)
                {
                    myPacket.RemoveRange(0, 2);
                    ProcessPingRequest(MySession, myPacket);
                    return;
                }

                Opcode = (ushort)(myPacket[3] << 8 | myPacket[2]);

                Logger.Info($"Message Length: {MessageLength}; OpcodeType: {MessageTypeOpcode.ToString("X")}; Message Number: {MessageNumber.ToString("X")}; Opcode: {Opcode.ToString("X")}.");

                ///Remove 4 read bytes (Opcode and Message #)
                myPacket.RemoveRange(0, 4);

                //Remove the opcode bytes we read
                MessageLength -= 2;

                ///Pass remaining to opcode checker for more processing
                OpcodeChecker(MySession, Opcode, myPacket, MessageLength);
            }

            ///Not expected order?
            ///Expand on eventually
            else
            {
                //Remove packet# and message bytes
                myPacket.RemoveRange(0, MessageLength + 2);
                return;
            }
        }
Exemplo n.º 29
0
 public Reply(MessageNumber conversationId = null)
 {
     ConvId = conversationId ?? MessageNumber.Create();
     MsgId  = MessageNumber.Create();
 }
Exemplo n.º 30
0
        public async Task CallsSecondBatchOfEvents_LastMessageNumberIsHigherThanOneBatchSize()
        {
            var httpClientWrapper =
                new FakeEventHttpClientWrapper(
                    resourceName: "test-message-type",
                    events: new List <EventInfo>
            {
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("9435310E-098B-4598-A378-5862D9A9E9AE")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("73DE4B51-1F0E-4428-8D59-8DFBEA8091BA")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("093626F4-7125-41CD-9982-785B7D52BCAA")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("C911BCDB-F23C-4FA3-BE57-E2C0EC3793DC")
                    }
                }
            });

            var apiHelper = new EventApi("http://localhost/", httpClientWrapper, TestResourceEventConverter.Instance,
                                         3);

            var result = await apiHelper.GetEventsAfterAsync(resourceName : "resource", lastMessageNumber : MessageNumber.New(3));

            Assert.Equal(1, httpClientWrapper.MessagesSent.Count);
            Assert.Equal("/events/resource/3-5", httpClientWrapper.MessagesSent[0].RequestUri.AbsolutePath);

            Assert.Equal(1, result.Count);
            Assert.Equal(new Guid("C911BCDB-F23C-4FA3-BE57-E2C0EC3793DC"), ((TestResourceCreatedEvent)result[0]).Id);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Default Constructed called by the Request and Reply constructors used by the Senders.
 /// Note how this construct creates a new message number and set the conversation Id to
 /// the message number.  This is the expected behavior for an initial messsage in a conversation.
 /// </summary>
 protected Message()
 {
     MessageNr      = MessageNumber.Create();
     ConversationId = MessageNr;
 }
Exemplo n.º 32
0
        public async Task MultipleCallsUntilAllEventsAreRetrieved_EventsCoverMultipleBatches()
        {
            var httpClientWrapper =
                new FakeEventHttpClientWrapper(
                    resourceName: "test-message-type",
                    events: new List <EventInfo>
            {
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("9435310E-098B-4598-A378-5862D9A9E9AE")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("73DE4B51-1F0E-4428-8D59-8DFBEA8091BA")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("093626F4-7125-41CD-9982-785B7D52BCAA")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("C911BCDB-F23C-4FA3-BE57-E2C0EC3793DC")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("00DE8FA8-98E7-4E65-8CE0-B3C982BD1B03")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("F2E3B971-28C9-474E-9EFA-231C86A673B4")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("76027085-3B4C-4724-A88C-375E5AB24E7A")
                    }
                },
                new EventInfo
                {
                    EventType = "resource-created",
                    Event     =
                        new TestResourceCreatedEvent
                    {
                        Id = new Guid("E34AD640-B4D0-4A31-9A19-7F1B869937C2")
                    }
                }
            });

            var apiHelper = new EventApi("http://localhost/", httpClientWrapper, TestResourceEventConverter.Instance,
                                         3);

            var result = await apiHelper.GetEventsAfterAsync(resourceName : "resource", lastMessageNumber : MessageNumber.New(3));

            Assert.Equal(3, httpClientWrapper.MessagesSent.Count);
            Assert.Equal("/events/resource/3-5", httpClientWrapper.MessagesSent[0].RequestUri.AbsolutePath);
            Assert.Equal("/events/resource/6-8", httpClientWrapper.MessagesSent[1].RequestUri.AbsolutePath);
            Assert.Equal("/events/resource/9-11", httpClientWrapper.MessagesSent[2].RequestUri.AbsolutePath);

            Assert.Equal(5, result.Count);
            Assert.Equal(new Guid("C911BCDB-F23C-4FA3-BE57-E2C0EC3793DC"), ((TestResourceCreatedEvent)result[0]).Id);
            Assert.Equal(new Guid("00DE8FA8-98E7-4E65-8CE0-B3C982BD1B03"), ((TestResourceCreatedEvent)result[1]).Id);
            Assert.Equal(new Guid("F2E3B971-28C9-474E-9EFA-231C86A673B4"), ((TestResourceCreatedEvent)result[2]).Id);
            Assert.Equal(new Guid("76027085-3B4C-4724-A88C-375E5AB24E7A"), ((TestResourceCreatedEvent)result[3]).Id);
            Assert.Equal(new Guid("E34AD640-B4D0-4A31-9A19-7F1B869937C2"), ((TestResourceCreatedEvent)result[4]).Id);
        }
Exemplo n.º 33
0
 protected bool ValidateConversationState(MessageNumber requestConvId, MessageNumber replyConvId)
 {
     return requestConvId == replyConvId;
 }
Exemplo n.º 34
0
 public LoginReply(MessageNumber convId) : base(convId)
 {
 }