<commit_before>﻿using System.Runtime.Serialization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;

namespace NJsonSchema.Tests.Generation
{
    [TestClass]
    public class IgnoredPropertyTests
    {
        public class Mno
        {
            public string IncludeMe;

            [JsonIgnore]
            public string IgnoreMe;
        }

        [DataContract]
        public class Xyz
        {
            [DataMember]
            public string IncludeMe;

            public string IgnoreMe;
        }

        [TestMethod]
        public void When_field_has_JsonIgnoreAttribute_then_it_is_ignored()
        {
            //// Arrange
            var schema = JsonSchema4.FromType<Mno>();

            //// Act
            var json = schema.ToJson();

            //// Assert
            Assert.IsFalse(json.Contains("IgnoreMe"));
        }

        [TestMethod]
        public void When_field_has_no_DataMemberAttribute_then_it_is_ignored()
        {
            //// Arrange
            var schema = JsonSchema4.FromType<Xyz>();

            //// Act
            var json = schema.ToJson();

            //// Assert
            Assert.IsFalse(json.Contains("IgnoreMe"));
        }
    }
}<commit_msg>Added unit test<commit_after>﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;

namespace NJsonSchema.Tests.Generation
{
    [TestClass]
    public class IgnoredPropertyTests
    {
        public class Mno
        {
            public string IncludeMe;

            [JsonIgnore]
            public string IgnoreMe;
        }


        [TestMethod]
        public void When_field_has_JsonIgnoreAttribute_then_it_is_ignored()
        {
            //// Arrange
            var schema = JsonSchema4.FromType<Mno>();

            //// Act
            var json = schema.ToJson();

            //// Assert
            Assert.IsFalse(json.Contains("IgnoreMe"));
        }

        [DataContract]
        public class Xyz
        {
            [DataMember]
            public string IncludeMe;

            public string IgnoreMe;
        }

        [TestMethod]
        public void When_field_has_no_DataMemberAttribute_then_it_is_ignored()
        {
            //// Arrange
            var schema = JsonSchema4.FromType<Xyz>();

            //// Act
            var json = schema.ToJson();

            //// Assert
            Assert.IsFalse(json.Contains("IgnoreMe"));
        }

        public class Foo
        {
            public Dictionary<string, object> DynamicValues { get; set; }

            [JsonIgnore]
            public object this[string key]
            {
                get { throw new NotImplementedException(); }
            }

            public string Bar { get; set; }
        }

        [TestMethod]
        public void When_indexer_property_has_ignore_attribute_then_it_is_ignored()
        {
            //// Arrange
            var schema = JsonSchema4.FromType<Foo>();

            //// Act
            var json = schema.ToJson();

            //// Assert
            Assert.AreEqual(2, schema.Properties.Count);
        }
    }
}
{'fraction_non_alphanumeric': 0.090795631825273, 'fraction_numerical': 0.00187207488299532, 'mean_word_length': 1.520440251572327, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6015705', 'n_tokens_mistral': 867, 'n_tokens_neox': 813, 'n_words': 166}