Exemplo n.º 1
0
        public void ShouldEmitAll()
        {
            var subjectUnderTest = new JsonProtocolWriterFormat();
            var emitJson         =
                subjectUnderTest.EmitCommand(new object[] { "field1", 2, 3 }, 1231231, 9, 1.ToString(CultureInfo.InvariantCulture));

            Assert.That(
                emitJson,
                Is.EqualTo(JsonStrings.CommandEmitAll().TrimStuffForCompare()));
        }
Exemplo n.º 2
0
        public void ShouldEmitWithTaskIdBecauseDirect()
        {
            var tuple = new Object[0];
            var emit  = JsonStrings.CommandEmitAll();

            var format = Substitute.For <IProtocolWriterFormat>();

            format.EmitCommand(tuple, 11, 22, "1").Returns(emit);

            var writer = Substitute.For <IWriteNext>();
            var reader = Substitute.For <IStormReader>();

            var subjectUnderTest = new StandardSpoutWriter(writer, format, reader);

            subjectUnderTest.EmitTupleDirect(tuple, 22, 11, "1");

            writer.Received().Write(emit);
            reader.DidNotReceive().ReadTaskIds();
        }
Exemplo n.º 3
0
        public void ShouldEmitAndReturnTaskIdsBecauseNotDirect()
        {
            var tuple = new object[0];
            var emit  = JsonStrings.CommandEmitAll();

            var format = Substitute.For <IProtocolWriterFormat>();

            format.EmitCommand(tuple, 11, null, "1").Returns(emit);

            var writer = Substitute.For <IWriteNext>();
            var reader = Substitute.For <IStormReader>();

            reader.ReadTaskIds().Returns(new long[] { 1, 2, 3 });

            var subjectUnderTest = new StandardSpoutWriter(writer, format, reader);

            Assert.That(subjectUnderTest.EmitTuple(tuple, 11, "1"), Is.EquivalentTo(new long[] { 1, 2, 3 }));

            writer.Received().Write(emit);
        }