Пример #1
0
        public void Serialize_To_Json_Without_Id()
        {
            // arrange
            var serializerResolver = new Mock <IValueSerializerCollection>();
            var formatter          = new JsonOperationFormatter(serializerResolver.Object);
            var formatterOptions   = new OperationFormatterOptions(includeId: false);
            var operation          = new Operation();
            var messageWriter      = new MessageWriter();

            // act
            formatter.Serialize(operation, messageWriter, formatterOptions);

            // assert
            Encoding.UTF8.GetString(messageWriter.Body.Span).MatchSnapshot();
        }
Пример #2
0
        public void Serialize_To_Json_With_Variables()
        {
            // arrange
            var serializerResolver = new Mock <IValueSerializerCollection>();

            serializerResolver.Setup(t => t.Get(It.IsAny <string>()))
            .Returns(new StringValueSerializer());
            var formatter        = new JsonOperationFormatter(serializerResolver.Object);
            var formatterOptions = new OperationFormatterOptions();
            var operation        = new OperationWithVariables();
            var messageWriter    = new MessageWriter();

            // act
            formatter.Serialize(operation, messageWriter, formatterOptions);

            // assert
            Encoding.UTF8.GetString(messageWriter.Body.Span).MatchSnapshot();
        }
Пример #3
0
        public void Serialize_To_Json_With_Extensions()
        {
            // arrange
            var serializerResolver = new Mock <IValueSerializerCollection>();
            var formatter          = new JsonOperationFormatter(serializerResolver.Object);
            var formatterOptions   = new OperationFormatterOptions(
                new Dictionary <string, object?>
            {
                { "key", "value" }
            });
            var operation     = new Operation();
            var messageWriter = new MessageWriter();

            // act
            formatter.Serialize(operation, messageWriter, formatterOptions);

            // assert
            Encoding.UTF8.GetString(messageWriter.Body.Span).MatchSnapshot();
        }