public void Setup()
        {
            var pages = new MemoryPageReaderWriter();
            var checkpoint = new MemoryCheckpointReaderWriter();

            Writer = new MessageWriter(pages, checkpoint);
            Reader = new MessageReader(checkpoint, pages);
            CheckpointReader = checkpoint;
            PageWriter = pages;
            Writer.Init();
        }
        public void ShouldWriteStartGroup()
        {
            var output = new MemoryStream();
            var writer = new MessageWriter(output, new GroupEncodingObjectWriterStrategy());
            writer.WriteObject(new Test1(), 1);

            output.Position = 0;
            Assert.AreEqual(
                (byte)MessageTag.AsInt(1, WireType.StartGroup),
                output.ReadByte());
        }
        public void ShouldTerminateWithEndGroup()
        {
            var output = new MemoryStream();
            var writer = new MessageWriter(output, new GroupEncodingObjectWriterStrategy());
            writer.WriteObject(new Test1(), 1);

            var bytes = output.ToArray();

            Assert.AreEqual(
                (byte)MessageTag.AsInt(1, WireType.EndGroup),
                bytes[bytes.Length - 1]);
        }
        public void ShouldNotIncludeLength()
        {
            var output = new MemoryStream();
            var writer = new MessageWriter(output, new GroupEncodingObjectWriterStrategy());
            writer.WriteObject(new Test1(), 1);

            var bytes = output.ToArray();

            Assert.AreEqual(
                (byte)MessageTag.AsInt(1, WireType.Varint),
                bytes[1]);
        }
        public void ShouldSupportGroups()
        {
            var input = new MemoryStream();
            var writer = new MessageWriter(input)
                .WriteHeader(1, WireType.Varint)
                .WriteVarint(42)
                .WriteHeader(2, WireType.Fixed32)
                .WriteFixed(0xdeadbeef)
                .WriteHeader(5, WireType.EndGroup);
            input.Position = 0;
            var field = UnknownField.Create(new MessageTag(5, WireType.StartGroup), new MessageReader(input));
            var nested = field.Value as UnknownFieldCollection;

            Assert.AreEqual(2, nested.Count);
        }
        public void WriteDescription_OneItemHasFailed_CorrectKeywordsForActualValue()
        {
            var cells = new FormattedResults();
            cells.Add("$185,125.12");
            cells.Add("$125.12");
            cells.Add("$125");

            var matchPatternConstraint = new MatchPatternConstraint();
            matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$");

            //Method under test
            var res = matchPatternConstraint.Matches(cells);

            var msg = new MessageWriter();
            matchPatternConstraint.WriteActualValueTo(msg);

            //Test conclusion
            Assert.That(msg.Message, Is.StringContaining("$125")
                .And.StringContaining("doesn't validate this pattern"));
        }
        public void Setup()
        {
            _folder = Path.Combine(Path.GetTempPath(), "syntethic_test");
            if (!Directory.Exists(_folder)) {
                Directory.CreateDirectory(_folder);
            }

            var streamFile = new FileInfo(Path.Combine(_folder, Constants.StreamFileName));
            var checkFile = new FileInfo(Path.Combine(_folder, Constants.PositionFileName));

            var pageWriter = new FilePageWriter(streamFile);
            var pageReader = new FilePageReader(streamFile);
            var checkReader = new FileCheckpointReader(checkFile);
            var checkWriter = new FileCheckpointWriter(checkFile);

            Writer = new MessageWriter(pageWriter, checkWriter);
            Reader = new MessageReader(checkReader, pageReader);
            CheckpointReader = checkReader;
            PageWriter = pageWriter;
            Writer.Init();
        }
 public override void WriteActualValueTo(MessageWriter writer)
 {
     writer.WriteActualValue(_valueToBeTested);
 }
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     writer.WriteExpectedValue(
         string.Format("A value {0} within tolerance of plus or minus {1}", _baseValue, _tolerance));
 }
Beispiel #10
0
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     writer.Write("always");
 }
Beispiel #11
0
        public void WriteMessage_WithRepeatedTest1()
        {
            var message = new WithRepeatedTest1();
            message.Data.Add(new Test1() { A = 42 });
            message.Data.Add(new Test1() { A = 0xbeef });

            var expected = new MemoryStream();
            var writer = new MessageWriter(expected);
            var embedded = new MemoryStream();
            var embeddedWriter = new MessageWriter(embedded);

            Serializer.Serialize(embeddedWriter, message.Data[0]);
            writer.WriteHeader(2, WireType.String);
            writer.WriteBytes(embedded.ToArray());

            embedded.SetLength(0);
            Serializer.Serialize(embeddedWriter, message.Data[1]);
            writer.WriteHeader(2, WireType.String);
            writer.WriteBytes(embedded.ToArray());
            Assert.AreEqual(expected.ToArray(), MessageWriter.Write(message));
        }
 public override void WriteMessageTo(MessageWriter writer)
 {
     writer.Write($"Elapsed time of {ActualValue}ms exceeds maximum of {_constraint._milliseconds}ms");
 }
Beispiel #13
0
			public InMemStream() {
				Pages = new MemoryPageReaderWriter();
				Pages.Init();
				Checkpoint = new MemoryCheckpointReaderWriter();
				Writer = new MessageWriter(Pages, Checkpoint);
			}