Example #1
0
        public void ValidHash()
        {
            using (var mem = new MemoryStream()) {
                var messages = GenerateMessages(7);
                TransferFormat.WriteMessages(messages, mem);
                mem.Seek(0, SeekOrigin.Begin);

                var actual = TransferFormat.ReadMessages(mem);

                AssertEqual(messages, actual);
            }
        }
Example #2
0
        public async Task <PostMessagesResponse> PostMessagesAsync(string stream, ICollection <Message> messages)
        {
            using (var mem = StreamFactory()) {
                TransferFormat.WriteMessages(messages, mem);

                mem.Seek(0, SeekOrigin.Begin);

                using (var sc = new StreamContent(mem)) {
                    var result = await _client.PostAsync("/streams/" + GetRealStreamName(stream), sc).ConfigureAwait(false);

                    result.EnsureSuccessStatusCode();
                    var content = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

                    return(JsonConvert.DeserializeObject <PostMessagesResponse>(content));
                }
            }
        }
Example #3
0
        public void InValidHash()
        {
            using (var mem = new MemoryStream()) {
                var messages = GenerateMessages(7);
                TransferFormat.WriteMessages(messages, mem);

                // zero the hash
                mem.Seek(-16, SeekOrigin.Current);
                mem.Write(new byte[16], 0, 4);

                mem.Seek(0, SeekOrigin.Begin);

                var actual = TransferFormat.ReadMessages(mem);

                AssertEqual(messages, actual);
            }
        }