Пример #1
0
        public void TestFieldCtor_EmptyFieldName_ThrowsArgumentException()
        {
            // Arrange
            string fieldName = String.Empty;
            string fieldType = "int";

            // Act
            SGClassField field = new SGClassField(fieldName, fieldType);
        }
Пример #2
0
        public void TestFieldCtor_NullFieldName_ThrowsArgumentNullException()
        {
            // Arrange
            string fieldName = null;
            string fieldType = "int";

            // Act
            SGClassField field = new SGClassField(fieldName, fieldType);
        }
Пример #3
0
        public void TestTypeValueSetNull_WithSystemType_FluentAPI_ThrowsArgumentNullException()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            Type         newFieldType = null;
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field = field.WithTypeValue(newFieldType);
        }
Пример #4
0
        public void TestTypevalueSetEmpty_Property_ThrowsArgumentException()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            string       newFieldType = String.Empty;
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field.FieldType = newFieldType;
        }
Пример #5
0
        public void TestTypeValueSetNull_Property_ThrowsArgumentNullException()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            string       newFieldType = null;
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field.FieldType = newFieldType;
        }
Пример #6
0
        public void TestFieldNameSetNull_FluentAPI_ThrowsArgumentNullException()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            string       newFieldName = null;
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field = field.WithFieldName(newFieldName);
        }
Пример #7
0
        public void TestTypevalueSetEmpty_FluentAPI_ThrowsArgumentException()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            string       newFieldType = String.Empty;
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field = field.WithTypeValue(newFieldType);
        }
Пример #8
0
        public void TestAccessibilityLevelSetNull_FluentAPI_ThrowsArgumentNullException()
        {
            // Arrange
            string fieldName = "field";
            string fieldType = "int";
            SGAccessibilityLevel accessibilityLevel    = SGAccessibilityLevel.Public;
            SGAccessibilityLevel newAccessibilityLevel = null;
            SGClassField         field = new SGClassField(fieldName, fieldType, accessibilityLevel);

            // Act
            field = field.WithAccessibilityLevel(newAccessibilityLevel);
        }
Пример #9
0
        public void TestFieldCtor_FieldNameWithSpaces_ReplacedWithUnderscores()
        {
            // Arrange
            string fieldName = "Some Field Name";
            string fieldType = "int";

            // Act
            SGClassField field = new SGClassField(fieldName, fieldType);

            // Assert
            Assert.AreEqual(fieldName.Replace(" ", "_"), field.FieldName);
        }
Пример #10
0
        public void TestFieldCtor_TypedFieldType_InitsFields()
        {
            // Arrange
            string fieldName = "field";
            Type   fieldType = typeof(int);

            // Act
            SGClassField field = new SGClassField(fieldName, fieldType);

            // Assert
            Assert.AreEqual(fieldType.Name, field.FieldType);
        }
Пример #11
0
        public void TestAccessibilityLevelSetNull_PropertyInitializer_ThrowsArgumentNullException()
        {
            // Arrange
            string fieldName = "field";
            string fieldType = "int";
            SGAccessibilityLevel accessibilityLevel = null;

            // Act
            SGClassField field = new SGClassField(fieldName, fieldType)
            {
                AccessibilityLevel = accessibilityLevel
            };
        }
Пример #12
0
        public void TestSetConstFlag_PropertySetter()
        {
            // Arrange
            string       fieldName = "field";
            string       fieldType = "int";
            bool         isConst   = true;
            SGClassField field     = new SGClassField(fieldName, fieldType);

            // Act
            field.IsConst = isConst;

            // Assert
            Assert.IsTrue(field.IsConst);
        }
Пример #13
0
        public void TestTypeValueSet_WithSystemType_FluentAPI()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            Type         newFieldType = typeof(bool);
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field = field.WithTypeValue(newFieldType);

            // Assert
            Assert.AreEqual(newFieldType.Name, field.FieldType);
        }
Пример #14
0
        public void TestFieldNameSet_WithSpaces_FluentAPI_ReplacedWithUnderscores()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            string       newFieldName = "some New Field Name";
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field = field.WithFieldName(newFieldName);

            // Assert
            Assert.AreEqual(newFieldName.Replace(" ", "_"), field.FieldName);
        }
Пример #15
0
        public void TestSetInitializationValue_Int()
        {
            // Arrange
            string       fieldName           = "field";
            string       fieldType           = "int";
            int          initializationValue = 5;
            SGClassField field = new SGClassField(fieldName, fieldType);

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

            // Assert
            Assert.AreEqual("5", field.InitializationValue);
        }
Пример #16
0
        public void TestSetInitializationValue_EmptyString()
        {
            // Arrange
            string       fieldName           = "field";
            string       fieldType           = "int";
            string       initializationValue = String.Empty;
            SGClassField field = new SGClassField(fieldName, fieldType);

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

            // Assert
            Assert.AreEqual($"\"\"", field.InitializationValue);
        }
Пример #17
0
        public void TestSetInitializationValue_FluentAPI()
        {
            // Arrange
            string       fieldName           = "field";
            string       fieldType           = "int";
            object       initializationValue = 5;
            SGClassField field = new SGClassField(fieldName, fieldType);

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

            // Assert
            Assert.AreEqual(initializationValue.ToString(), field.InitializationValue);
        }
Пример #18
0
        public void TestTypeValueSet_FluentAPI()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            string       newFieldType = "bool";
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field = field.WithTypeValue(newFieldType);

            // Assert
            Assert.AreEqual(newFieldType, field.FieldType);
        }
Пример #19
0
        public void TestSetReadonlyFlag_FluentAPI()
        {
            // Arrange
            string       fieldName  = "field";
            string       fieldType  = "int";
            bool         isReadonly = true;
            SGClassField field      = new SGClassField(fieldName, fieldType);

            // Act
            field = field.WithIsReadonly(isReadonly);

            // Assert
            Assert.IsTrue(field.IsReadonly);
        }
Пример #20
0
        public void TestSetInitializationValue_PropertySetter()
        {
            // Arrange
            string       fieldName           = "field";
            string       fieldType           = "int";
            string       initializationValue = "5";
            SGClassField field = new SGClassField(fieldName, fieldType);

            // Act
            field.InitializationValue = initializationValue;

            // Assert
            Assert.AreEqual(initializationValue, field.InitializationValue);
        }
Пример #21
0
        public void TestSetStaticFlag_FluentAPI()
        {
            // Arrange
            string       fieldName = "field";
            string       fieldType = "int";
            bool         isStatic  = true;
            SGClassField field     = new SGClassField(fieldName, fieldType);

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

            // Assert
            Assert.IsTrue(field.IsStatic);
        }
Пример #22
0
        public void TestSetReadonlyFlag_PropertySetter()
        {
            // Arrange
            string       fieldName  = "field";
            string       fieldType  = "int";
            bool         isReadonly = true;
            SGClassField field      = new SGClassField(fieldName, fieldType);

            // Act
            field.IsReadonly = isReadonly;

            // Assert
            Assert.IsTrue(field.IsReadonly);
        }
Пример #23
0
        public void TestSetStaticFlag_PropertySetter()
        {
            // Arrange
            string       fieldName = "field";
            string       fieldType = "int";
            bool         isStatic  = true;
            SGClassField field     = new SGClassField(fieldName, fieldType);

            // Act
            field.IsStatic = isStatic;

            // Assert
            Assert.IsTrue(field.IsStatic);
        }
Пример #24
0
        public void TestFieldNameSet()
        {
            // Arrange
            string       fieldName    = "field";
            string       fieldType    = "int";
            string       newFieldName = "newField";
            SGClassField field        = new SGClassField(fieldName, fieldType);

            // Act
            field.FieldName = newFieldName;

            // Assert
            Assert.AreEqual(newFieldName, field.FieldName);
        }
Пример #25
0
        public void TestAccessibilityLevelSet_FluentAPI()
        {
            // Arrange
            string fieldName = "field";
            string fieldType = "int";
            SGAccessibilityLevel accessibilityLevel    = SGAccessibilityLevel.Public;
            SGAccessibilityLevel newAccessibilityLevel = SGAccessibilityLevel.Protected;
            SGClassField         field = new SGClassField(fieldName, fieldType, accessibilityLevel);

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

            // Assert
            Assert.AreEqual(newAccessibilityLevel, field.AccessibilityLevel);
        }
Пример #26
0
        public void TestAccessibilityLevelSet_PropertyInitializer()
        {
            // Arrange
            string fieldName = "field";
            string fieldType = "int";
            SGAccessibilityLevel accessibilityLevel = SGAccessibilityLevel.Public;

            // Act
            SGClassField field = new SGClassField(fieldName, fieldType)
            {
                AccessibilityLevel = accessibilityLevel
            };

            // Assert
            Assert.AreEqual(accessibilityLevel, field.AccessibilityLevel);
        }
Пример #27
0
        public void TestFieldCtor_Defaults_InitsFields()
        {
            // Arrange
            string fieldName = "field";
            string fieldType = "int";

            // Act
            SGClassField field = new SGClassField(fieldName, fieldType);

            // Assert
            Assert.AreEqual(fieldName, field.FieldName);
            Assert.AreEqual(fieldType, field.FieldType);
            Assert.AreEqual(SGAccessibilityLevel.Private, field.AccessibilityLevel);
            Assert.IsFalse(field.IsStatic);
            Assert.IsFalse(field.IsConst);
            Assert.IsFalse(field.IsReadonly);
        }
Пример #28
0
        public void TestFieldCtor_InitsFields()
        {
            // Arrange
            string fieldName = "field";
            SGAccessibilityLevel accessibilityLevel = SGAccessibilityLevel.Public;
            string fieldType = "int";
            bool   @static   = true;
            bool   @const    = true;
            bool   @readonly = true;

            // Act
            SGClassField field = new SGClassField(fieldName, fieldType, accessibilityLevel, @static, @const, @readonly);

            // Assert
            Assert.AreEqual(fieldName, field.FieldName);
            Assert.AreEqual(accessibilityLevel, field.AccessibilityLevel);
            Assert.AreEqual(fieldType, field.FieldType);
            Assert.AreEqual(@static, field.IsStatic);
            Assert.AreEqual(@const, field.IsConst);
            Assert.AreEqual(@readonly, field.IsReadonly);
        }