Ejemplo n.º 1
0
        public void GetPropertyForJsonKey_returns_correct_value_for_custom_id()
        {
            // Arrange
            var pluralizationService = new PluralizationService();
            var mm = new ModelManager(pluralizationService);
            Type bandType = typeof(Band);
            mm.RegisterResourceType(bandType);

            // Act
            var idProp = mm.GetPropertyForJsonKey(bandType, "id");

            // Assert
            idProp.Property.Should().BeSameAs(bandType.GetProperty("BandName"));
            idProp.Should().BeOfType<FieldModelProperty>();
        }
Ejemplo n.º 2
0
        public void GetPropertyForJsonKey_returns_correct_value_for_JsonProperty_attribute()
        {
            // Arrange
            var pluralizationService = new PluralizationService();
            var mm = new ModelManager(pluralizationService);
            Type bandType = typeof(Band);
            mm.RegisterResourceType(bandType);

            // Act
            var prop = mm.GetPropertyForJsonKey(bandType, "THE-GENRE");

            // Assert
            prop.Property.Should().BeSameAs(bandType.GetProperty("Genre"));
            prop.Should().BeOfType<FieldModelProperty>();
        }
Ejemplo n.º 3
0
        public void GetPropertyForJsonKeyTest()
        {
            // Arrange
            var pluralizationService = new PluralizationService();
            var mm = new ModelManager(pluralizationService);
            Type authorType = typeof(Author);
            mm.RegisterResourceType(authorType);

            // Act
            var idProp = mm.GetPropertyForJsonKey(authorType, "id");
            var nameProp = mm.GetPropertyForJsonKey(authorType, "name");
            var postsProp = mm.GetPropertyForJsonKey(authorType, "posts");

            // Assert
            idProp.Property.Should().BeSameAs(authorType.GetProperty("Id"));
            idProp.Should().BeOfType<FieldModelProperty>();

            nameProp.Property.Should().BeSameAs(authorType.GetProperty("Name"));
            nameProp.Should().BeOfType<FieldModelProperty>();

            postsProp.Property.Should().BeSameAs(authorType.GetProperty("Posts"));
            postsProp.Should().BeOfType<RelationshipModelProperty>();
        }