Пример #1
0
        public void IndexerSkipped()
        {
            PropertyAnalyzer propertyAnalyzer = new PropertyAnalyzer(new IntIdGenerator(), Mock.Of <IPropertyNameGenerator>());
            var actual = propertyAnalyzer.AnalyzeProperties(typeof(SimpleClassWithIndexer), null, false).ToList();

            Assert.Equal(0, actual.Count);
        }
Пример #2
0
        private void AnalyzeProperty(SymbolAnalysisContext context, [NotNull] SymbolAnalyzerFactory factory,
                                     [NotNull] ImmutableDictionary <string, string> properties)
        {
            PropertyAnalyzer analyzer = factory.GetPropertyAnalyzer(context);

            analyzer.Analyze(ruleForProperty, properties);
        }
Пример #3
0
        public void IsReadOnlySet()
        {
            PropertyAnalyzer propertyAnalyzer = new PropertyAnalyzer(new IntIdGenerator(), new IdentityNameGenerator());
            var actual = propertyAnalyzer.AnalyzeProperties(typeof(SimpleClassWithPrimitiveProperties), null, false).ToList();

            Assert.False(actual.Single(f => f.Name == nameof(SimpleClassWithPrimitiveProperties.StringProperty)).Writable);
        }
Пример #4
0
        public void IdsSetForProperties()
        {
            PropertyAnalyzer propertyAnalyzer = new PropertyAnalyzer(new IntIdGenerator(), Mock.Of <IPropertyNameGenerator>());
            var actual = propertyAnalyzer.AnalyzeProperties(typeof(SimpleClassWithPrimitiveProperties), null, false).ToList();

            Assert.Collection(actual, f => Assert.Equal(1, f.Id), f => Assert.Equal(2, f.Id), f => Assert.Equal(3, f.Id));
        }
Пример #5
0
        public void NamesSetForProperties()
        {
            PropertyAnalyzer propertyAnalyzer = new PropertyAnalyzer(new IntIdGenerator(), new IdentityNameGenerator());
            var actual = propertyAnalyzer.AnalyzeProperties(typeof(SimpleClassWithPrimitiveProperties), null, false).ToList();

            Assert.Collection(actual,
                              f => Assert.Equal(nameof(SimpleClassWithPrimitiveProperties.IntProperty), f.Name),
                              f => Assert.Equal(nameof(SimpleClassWithPrimitiveProperties.DoubleProperty), f.Name),
                              f => Assert.Equal(nameof(SimpleClassWithPrimitiveProperties.StringProperty), f.Name));
        }
Пример #6
0
        public void SettersSet()
        {
            PropertyAnalyzer propertyAnalyzer = new PropertyAnalyzer(new IntIdGenerator(), new IdentityNameGenerator());
            var actual = propertyAnalyzer.AnalyzeProperties(typeof(SimpleClassWithPrimitiveProperties), null, false).ToList();

            const int    IntValue    = 3;
            const double DoubleValue = 3.0;
            var          obj         = new SimpleClassWithPrimitiveProperties("str")
            {
            };

            actual[0].Setter(obj, IntValue);
            actual[1].Setter(obj, DoubleValue);

            Assert.Equal(IntValue, obj.IntProperty);
            Assert.Equal(DoubleValue, obj.DoubleProperty);
        }
Пример #7
0
        public void GettersSet()
        {
            PropertyAnalyzer propertyAnalyzer = new PropertyAnalyzer(new IntIdGenerator(), new IdentityNameGenerator());
            var actual = propertyAnalyzer.AnalyzeProperties(typeof(SimpleClassWithPrimitiveProperties), null, false).ToList();

            const int    IntValue    = 3;
            const double DoubleValue = 3.0;
            const string StringValue = "string";
            var          obj         = new SimpleClassWithPrimitiveProperties(StringValue)
            {
                IntProperty    = IntValue,
                DoubleProperty = DoubleValue
            };

            Assert.Equal(IntValue, actual[0].Getter(obj));
            Assert.Equal(DoubleValue, actual[1].Getter(obj));
            Assert.Equal(StringValue, actual[2].Getter(obj));
        }
Пример #8
0
 public void SetUp()
 {
     Analyzer = new PropertyAnalyzer();
 }