Provides functionality to serialize the result of LINQ tests into a human-readable and machine-readable format for comparison between tests.
 private static string GetActualResult (object queryResult)
 {
   var stringWriter = new StringWriter();
   // Ignore bidirectional associations - we are only interested in the foreign key properties of associations (eg., CategoryID rather than Category)
   var serializer = new TestResultSerializer (stringWriter, info => !info.IsDefined (typeof (System.Data.Linq.Mapping.AssociationAttribute), false));
   serializer.Serialize (queryResult);
   return stringWriter.ToString();
 }
        private static string GetActualResult(object queryResult)
        {
            var stringWriter = new StringWriter();
            // Ignore bidirectional associations - we are only interested in the foreign key properties of associations (eg., CategoryID rather than Category)
            var serializer = new TestResultSerializer(stringWriter, info => !info.IsDefined(typeof(System.Data.Linq.Mapping.AssociationAttribute), false));

            serializer.Serialize(queryResult);
            return(stringWriter.ToString());
        }
    public void Execute (object queryResult, MethodBase executingMethod)
    {
      var resourceName = _resourceFileNameGenerator (executingMethod);
      if (!Directory.Exists (_directory))
        Directory.CreateDirectory (_directory);

      var fileName = Path.Combine (_directory, resourceName);
      using (var writer = File.CreateText(fileName))
      {
        var serializer = new TestResultSerializer (writer, info => !info.IsDefined (typeof (System.Data.Linq.Mapping.AssociationAttribute), false));
        serializer.Serialize (queryResult);
      }
    }
        private void SerializeEnumerable(IEnumerable value)
        {
            Assertion.DebugAssert(value != null, "should be handled by caller");

            _textWriter.Write("Enumerable");
            _textWriter.WriteLine(" {");
            TestResultSerializer elementSerializer = CreateIndentedSerializer();

            foreach (var element in value)
            {
                elementSerializer.Serialize(element);
            }

            WriteSpacing();
            _textWriter.WriteLine("}");
        }
        public void Execute(object queryResult, MethodBase executingMethod)
        {
            var resourceName = _resourceFileNameGenerator(executingMethod);

            if (!Directory.Exists(_directory))
            {
                Directory.CreateDirectory(_directory);
            }

            var fileName = Path.Combine(_directory, resourceName);

            using (var writer = File.CreateText(fileName))
            {
                var serializer = new TestResultSerializer(writer, info => !info.IsDefined(typeof(System.Data.Linq.Mapping.AssociationAttribute), false));
                serializer.Serialize(queryResult);
            }
        }
 public void SetUp ()
 {
   _writer = new StringWriter ();
   _serializer = new TestResultSerializer (_writer);
   _serializerWithLevel1 = new TestResultSerializer (_writer, "..", 1);
 }
    public void Serialize_WithMemberFilterNested ()
    {
      var instance0 = new SerializerTestClassWithFields { PublicField1 = 11, PublicField2 = "test 0" };
      var instance1 = new SerializerTestClassWithFields { PublicField1 = 12, PublicField2 = "test 1" };
      var instance = new
      {
        EnumerableProperty = new[] { instance0, instance1 }
      };
      TestResultSerializer serializer = new TestResultSerializer (_writer, memberInfo => !memberInfo.Name.Equals("PublicField2"));

      serializer.Serialize (instance);
      var expected = "AnonymousType" + Environment.NewLine
                    + "  EnumerableProperty: Enumerable {" + Environment.NewLine
                    + "    SerializerTestClassWithFields" + Environment.NewLine
                    + "      PublicField1: 11" + Environment.NewLine
                    //+ "      PublicField2: 'test 0'" + Environment.NewLine
                    + "    SerializerTestClassWithFields" + Environment.NewLine
                    + "      PublicField1: 12" + Environment.NewLine
                    //+ "      PublicField2: 'test 1'" + Environment.NewLine
                    + "  }" + Environment.NewLine;

      Assert.That (_writer.ToString (), Is.EqualTo (expected));
    }
    public void Serialize_WithMemberFilter ()
    {
      var instance = new SerializerTestClassWithProperties { PublicProperty1 = 17, PublicProperty2 = "test" };
      TestResultSerializer serializer = new TestResultSerializer (_writer, memberInfo => memberInfo.Name.Contains ("1"));

      serializer.Serialize (instance);
      var expected = "SerializerTestClassWithProperties" + Environment.NewLine
          + "  PublicProperty1: 17" + Environment.NewLine;

      Assert.That (_writer.ToString (), Is.EqualTo (expected));
    }