Example #1
0
        public void TestPropertyCtor_EmptyPropertyName_ThrowsArgumentException()
        {
            // Arrange
            string propertyName = String.Empty;
            string propertyType = "int";

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType);
        }
Example #2
0
        public void TestPropertyCtor_NullPropertyName_ThrowsArgumentNullException()
        {
            // Arrange
            string propertyName = null;
            string propertyType = "int";

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType);
        }
Example #3
0
        public void TestPropertyTypeSetEmpty_FluentAPI_ThrowsArgumentException()
        {
            // Arrange
            string          propertyName    = "property";
            string          propertyType    = "int";
            string          newPropertyType = String.Empty;
            SGClassProperty property        = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithPropertyType(newPropertyType);
        }
Example #4
0
        public void TestSetSetterAccessibilityLevelNull_FluentAPI_ThrowsArgumentNullException()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel setterAccessLevel = null;
            SGClassProperty      property          = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithSetterAccessibilityLevel(setterAccessLevel);
        }
Example #5
0
        public void TestPropertyTypeSetNull_Property_ThrowsArgumentNullException()
        {
            // Arrange
            string          propertyName    = "property";
            string          propertyType    = "int";
            string          newPropertyType = null;
            SGClassProperty property        = new SGClassProperty(propertyName, propertyType);

            // Act
            property.PropertyType = newPropertyType;
        }
Example #6
0
        public void TestSetGetterAccessibilityLevelNull_Property_ThrowsArgumentNullException()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel getterAccessLevel = null;
            SGClassProperty      property          = new SGClassProperty(propertyName, propertyType);

            // Act
            property.GetterAccessibilityLevel = getterAccessLevel;
        }
Example #7
0
        public void TestPropertyTypeSetNull_WithSystemType_FluentAPI_ThrowsArgumentNullException()
        {
            // Arrange
            string          propertyName    = "property";
            string          propertyType    = "int";
            Type            newPropertyType = null;
            SGClassProperty property        = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithPropertyType(newPropertyType);
        }
Example #8
0
        public void TestPropertyCtor_PropertyNameWithSpaces_ReplacedWithUnderscores()
        {
            // Arrange
            string propertyName = "Some Property Name";
            string propertyType = "int";

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType);

            // Assert
            Assert.AreEqual(propertyName.Replace(" ", "_"), property.PropertyName);
        }
Example #9
0
        public void TestAccessibilityLevelSetNull_FluentAPI_ThrowsArgumentNullException()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel accessibilityLevel    = SGAccessibilityLevel.Public;
            SGAccessibilityLevel newAccessibilityLevel = null;
            SGClassProperty      property = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithAccessibilityLevel(newAccessibilityLevel);
        }
Example #10
0
        public void TestPropertyCtor_TypedPropertyType_InitsFields()
        {
            // Arrange
            string propertyName = "property";
            Type   propertyType = typeof(int);

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType);

            // Assert
            Assert.AreEqual(propertyType.Name, property.PropertyType);
        }
Example #11
0
        public void TestSetSetterAccessibilityLevelNull_PropertyInitializer_ThrowsArgumentNullException()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel setterAccessLevel = null;

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType)
            {
                SetterAccessibilityLevel = setterAccessLevel
            };
        }
Example #12
0
        public void TestSetGetterAccessibilityLevel_Property()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel getterAccessLevel = SGAccessibilityLevel.Public;
            SGClassProperty      property          = new SGClassProperty(propertyName, propertyType);

            // Act
            property.GetterAccessibilityLevel = getterAccessLevel;

            // Assert
            Assert.AreEqual(getterAccessLevel, property.GetterAccessibilityLevel);
        }
Example #13
0
        public void TestPropertyNameSet()
        {
            // Arrange
            string          propertyName    = "property";
            string          propertyType    = "int";
            string          newPropertyName = "newProperty";
            SGClassProperty property        = new SGClassProperty(propertyName, propertyType);

            // Act
            property.PropertyName = newPropertyName;

            // Assert
            Assert.AreEqual(newPropertyName, property.PropertyName);
        }
Example #14
0
        public void TestSetStaticFlag_PropertySetter()
        {
            // Arrange
            string          propertyName = "property";
            string          propertyType = "int";
            bool            isStatic     = true;
            SGClassProperty property     = new SGClassProperty(propertyName, propertyType);

            // Act
            property.IsStatic = isStatic;

            // Assert
            Assert.IsTrue(isStatic);
        }
Example #15
0
        public void TestPropertyNameSet_WithSpaces_FluentAPI_ReplacedWithUnderscores()
        {
            // Arrange
            string          propertyName    = "property";
            string          propertyType    = "int";
            string          newPropertyName = "Some Property Name";
            SGClassProperty property        = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithPropertyName(newPropertyName);

            // Assert
            Assert.AreEqual(newPropertyName.Replace(" ", "_"), property.PropertyName);
        }
Example #16
0
        public void TestPropertyTypeSet_FluentAPI()
        {
            // Arrange
            string          propertyName    = "property";
            string          propertyType    = "int";
            string          newPropertyType = "bool";
            SGClassProperty property        = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithPropertyType(newPropertyType);

            // Assert
            Assert.AreEqual(newPropertyType, property.PropertyType);
        }
Example #17
0
        public void TestPropertyTypeSet_WithSystemType_FluentAPI()
        {
            // Arrange
            string          propertyName    = "property";
            string          propertyType    = "int";
            Type            newPropertyType = typeof(bool);
            SGClassProperty property        = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithPropertyType(newPropertyType);

            // Assert
            Assert.AreEqual(newPropertyType.Name, property.PropertyType);
        }
Example #18
0
        public void TestSetStaticFlag_FluentAPI()
        {
            // Arrange
            string          propertyName = "property";
            string          propertyType = "int";
            bool            isStatic     = true;
            SGClassProperty property     = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithIsStatic(isStatic);

            // Assert
            Assert.IsTrue(isStatic);
        }
Example #19
0
        public void TestSetInitializationValue_Int()
        {
            // Arrange
            string          propertyName        = "property";
            string          propertyType        = "int";
            int             initializationValue = 5;
            SGClassProperty property            = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithInitializationValue(initializationValue);

            // Assert
            Assert.AreEqual("5", property.InitializationValue);
        }
Example #20
0
        public void TestSetInitializationValue_EmptyString()
        {
            // Arrange
            string          propertyName        = "property";
            string          propertyType        = "int";
            string          initializationValue = String.Empty;
            SGClassProperty property            = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithInitializationValue(initializationValue);

            // Assert
            Assert.AreEqual($"\"\"", property.InitializationValue);
        }
Example #21
0
        public void TestSetInitializationValue_String()
        {
            // Arrange
            string          propertyName        = "property";
            string          propertyType        = "int";
            object          initializationValue = "test string";
            SGClassProperty property            = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithInitializationValue(initializationValue);

            // Assert
            Assert.AreEqual($"\"{initializationValue}\"", property.InitializationValue);
        }
Example #22
0
        public void TestSetInitializationValue_PropertySetter()
        {
            // Arrange
            string          propertyName        = "property";
            string          propertyType        = "int";
            string          initializationValue = "5";
            SGClassProperty property            = new SGClassProperty(propertyName, propertyType);

            // Act
            property.InitializationValue = initializationValue;

            // Assert
            Assert.AreEqual(initializationValue, property.InitializationValue);
        }
Example #23
0
        public void TestSetInitializationValue_FluentAPI()
        {
            // Arrange
            string          propertyName        = "property";
            string          propertyType        = "int";
            object          initializationValue = 5;
            SGClassProperty property            = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithInitializationValue(initializationValue);

            // Assert
            Assert.AreEqual(initializationValue.ToString(), property.InitializationValue);
        }
Example #24
0
        public void TestSetSetterAccessibilityLevel_FluentAPI()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel setterAccessLevel = SGAccessibilityLevel.Public;
            SGClassProperty      property          = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithSetterAccessibilityLevel(setterAccessLevel);

            // Assert
            Assert.AreEqual(setterAccessLevel, property.SetterAccessibilityLevel);
        }
Example #25
0
        public void TestAccessibilityLevelSet_FluentAPI()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel accessibilityLevel    = SGAccessibilityLevel.Public;
            SGAccessibilityLevel newAccessibilityLevel = SGAccessibilityLevel.Protected;
            SGClassProperty      property = new SGClassProperty(propertyName, propertyType);

            // Act
            property = property.WithAccessibilityLevel(newAccessibilityLevel);

            // Assert
            Assert.AreEqual(newAccessibilityLevel, property.AccessibilityLevel);
        }
Example #26
0
        public void TestAccessibilityLevelSet_PropertyInitializer()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel accessibilityLevel = SGAccessibilityLevel.Public;

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType)
            {
                AccessibilityLevel = accessibilityLevel
            };

            // Assert
            Assert.AreEqual(accessibilityLevel, property.AccessibilityLevel);
        }
Example #27
0
        public void TestSetStaticFlag_PropertyInitializer()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            bool   isStatic     = true;

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType)
            {
                IsStatic = isStatic
            };

            // Assert
            Assert.IsTrue(isStatic);
        }
Example #28
0
        public void TestSetSetterAccessibilityLevel_PropertyInitializer()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel setterAccessLevel = SGAccessibilityLevel.Public;

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType)
            {
                SetterAccessibilityLevel = setterAccessLevel
            };

            // Assert
            Assert.AreEqual(setterAccessLevel, property.SetterAccessibilityLevel);
        }
Example #29
0
        public void TestPropertyCtor_Defaults_InitsFields()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType);

            // Assert
            Assert.AreEqual(propertyName, property.PropertyName);
            Assert.AreEqual(propertyType, property.PropertyType);
            Assert.AreEqual(SGAccessibilityLevel.Private, property.AccessibilityLevel);
            Assert.IsFalse(property.IsStatic);
            Assert.AreEqual(SGAccessibilityLevel.None, property.GetterAccessibilityLevel);
            Assert.AreEqual(SGAccessibilityLevel.None, property.SetterAccessibilityLevel);
        }
Example #30
0
        public void TestPropertyCtor_InitsFields()
        {
            // Arrange
            string propertyName = "property";
            string propertyType = "int";
            SGAccessibilityLevel accessibilityLevel = SGAccessibilityLevel.Public;
            bool @static = true;
            SGAccessibilityLevel getterAccessibilityLevel = SGAccessibilityLevel.Protected;
            SGAccessibilityLevel setterAccessibilityLevel = SGAccessibilityLevel.Internal;

            // Act
            SGClassProperty property = new SGClassProperty(propertyName, propertyType, accessibilityLevel, @static, getterAccessibilityLevel, setterAccessibilityLevel);

            // Assert
            Assert.AreEqual(propertyName, property.PropertyName);
            Assert.AreEqual(propertyType, property.PropertyType);
            Assert.AreEqual(accessibilityLevel, property.AccessibilityLevel);
            Assert.AreEqual(@static, property.IsStatic);
            Assert.AreEqual(getterAccessibilityLevel, property.GetterAccessibilityLevel);
            Assert.AreEqual(setterAccessibilityLevel, property.SetterAccessibilityLevel);
        }