예제 #1
0
        public void TestAddingInterfaces_PropertyInitializer()
        {
            // Arrange
            string      namespaceName = "SlnGen";
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(interfaceName);
            SGInterface interface2    = new SGInterface(interfaceName);

            // Act
            SGNamespace @namespace = new SGNamespace(namespaceName)
            {
                Interfaces =
                {
                    @interface,
                    interface2
                }
            };

            // Assert
            Assert.IsTrue(@namespace.Interfaces.ContainsAll(new List <SGInterface>
            {
                @interface,
                interface2
            }));
        }
예제 #2
0
        public void TestNullInterfaceNameNoAccessibility_ThrowsArgumentNullException()
        {
            // Arrange
            string interfaceName = null;

            // Act
            SGInterface @interface = new SGInterface(interfaceName);
        }
예제 #3
0
        public void TestEmptyInterfaceNameNoAccessibility_ThrowsArgumentException()
        {
            // Arrange
            string interfaceName = String.Empty;

            // Act
            SGInterface @interface = new SGInterface(interfaceName);
        }
예제 #4
0
        public void TestAddEmptyGeneric_ThrowsArgumentException()
        {
            // Arrange
            string interfaceName   = "IInterface";
            string genericTypeName = String.Empty;

            // Act
            SGInterface @interface = new SGInterface(interfaceName).WithGenericTypeNames(genericTypeName);
        }
예제 #5
0
        public void TestAddNullAttribute_ThrowsArgumentException()
        {
            // Arrange
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(interfaceName);

            // Act
            @interface = @interface.WithAttributes(null);
        }
예제 #6
0
        public void TestEmptyInterfaceName_ThrowsArgumentException()
        {
            // Arrange
            string interfaceName = String.Empty;
            SGAccessibilityLevel accessibilityLevel = SGAccessibilityLevel.Public;

            // Act
            SGInterface @interface = new SGInterface(accessibilityLevel, interfaceName);
        }
예제 #7
0
        public void TestAddEmptyInterfaceImplementation_ThrowsArgumentException()
        {
            // Arrange
            string interfaceName           = "IInterface";
            string interfaceImplementation = String.Empty;

            // Act
            SGInterface @interface = new SGInterface(interfaceName).WithImplementations(interfaceImplementation);
        }
예제 #8
0
        public void TestNamespaceNameSetNull_ThrowsArgumentNullException()
        {
            // Arrange
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(interfaceName);

            // Act
            @interface.InterfaceName = null;
        }
예제 #9
0
        public void TestAddNullMethodSignature_ThrowsArgumentException()
        {
            // Arrange
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(interfaceName);

            // Act
            @interface = @interface.WithMethodSignatures(null);
        }
예제 #10
0
        public void TestNamespaceNameSetEmpty_ThrowsArgumentException()
        {
            // Arrange
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(interfaceName);

            // Act
            @interface.InterfaceName = String.Empty;
        }
예제 #11
0
        public void TestIsGenericFlag_FalseWhenNotGeneric()
        {
            // Arrange
            string interfaceName = "IInterface";

            // Act
            SGInterface @interface = new SGInterface(interfaceName);

            // Assert
            Assert.IsFalse(@interface.IsGeneric);
        }
예제 #12
0
        public void TestInterfaceNameWithSpaces_ReplacedWithUnderscores()
        {
            // Arrange
            string interfaceName = "ISome Interface Name";

            // Act
            SGInterface @interface = new SGInterface(interfaceName);

            // Assert
            Assert.AreEqual(interfaceName.Replace(" ", "_"), @interface.InterfaceName);
        }
예제 #13
0
        public void TestInterfaceCtor_Name_InitsFields()
        {
            // Arrange
            string interfaceName = "IInterface";

            // Act
            SGInterface @interface = new SGInterface(interfaceName);

            // Assert
            Assert.AreEqual(interfaceName, @interface.InterfaceName);
            Assert.AreEqual(SGAccessibilityLevel.Private, @interface.AccessibilityLevel);
        }
예제 #14
0
        public void TestAccessibilityLevelSet_Property()
        {
            // Arrange
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(SGAccessibilityLevel.Private, interfaceName);

            // Act
            @interface.AccessibilityLevel = SGAccessibilityLevel.Public;

            // Assert
            Assert.AreEqual(SGAccessibilityLevel.Public, @interface.AccessibilityLevel);
        }
예제 #15
0
        public void TestAccessibilityLevelSet_FluentAPI()
        {
            // Arrange
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(SGAccessibilityLevel.Private, interfaceName);

            // Act
            @interface = @interface.WithAccessibilityLevel(SGAccessibilityLevel.Public);

            // Assert
            Assert.AreEqual(SGAccessibilityLevel.Public, @interface.AccessibilityLevel);
        }
예제 #16
0
        public void TestIsGenericFlag_TrueWhenGeneric()
        {
            // Arrange
            string interfaceName   = "IInterface";
            string genericTypeName = "T";

            // Act
            SGInterface @interface = new SGInterface(interfaceName).WithGenericTypeNames(genericTypeName);

            // Assert
            Assert.IsTrue(@interface.IsGeneric);
        }
예제 #17
0
        public void TestAddingInterface_FluentAPI()
        {
            // Arrange
            string      namespaceName = "SlnGen";
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(interfaceName);

            // Act
            SGNamespace @namespace = new SGNamespace(namespaceName).WithInterfaces(@interface);

            // Assert
            Assert.IsTrue(@namespace.Interfaces.Contains(@interface));
        }
예제 #18
0
        public void TestAddInterfaceImplementation_AsSGinterface_FluentAPI()
        {
            // Arrange
            string      interfaceName = "IInterface";
            SGInterface if1           = new SGInterface("IImp");
            SGInterface if2           = new SGInterface("IImp2");

            // Act
            SGInterface @interface = new SGInterface(interfaceName).WithImplementations(if1, if2);

            // Assert
            Assert.IsTrue(@interface.InterfaceImplementations.ContainsAll(if1.InterfaceName, if2.InterfaceName));
        }
예제 #19
0
        public void TestAddInterfaceImplementation_AsString_FluentAPI()
        {
            // Arrange
            string interfaceName         = "IInterface";
            string implementedInterface1 = "IImp";
            string implementedInterface2 = "IImp2";

            // Act
            SGInterface @interface = new SGInterface(interfaceName).WithImplementations(implementedInterface1, implementedInterface2);

            // Assert
            Assert.IsTrue(@interface.InterfaceImplementations.ContainsAll(implementedInterface1, implementedInterface2));
        }
예제 #20
0
        public void TestAddGeneric_FluentAPI()
        {
            // Arrange
            string interfaceName    = "IInterface";
            string genericTypeName  = "T";
            string genericTypeName2 = "U";

            // Act
            SGInterface @interface = new SGInterface(interfaceName).WithGenericTypeNames(genericTypeName, genericTypeName2);

            // Assert
            Assert.IsTrue(@interface.GenericTypeNames.ContainsAll(genericTypeName, genericTypeName2));
        }
예제 #21
0
        public void TestInterfaceCtor_NameAccessibility_InitsFields()
        {
            // Arrange
            string interfaceName = "IInterface";
            SGAccessibilityLevel accessibilityLevel = SGAccessibilityLevel.Public;

            // Act
            SGInterface @interface = new SGInterface(accessibilityLevel, interfaceName);

            // Assert
            Assert.AreEqual(interfaceName, @interface.InterfaceName);
            Assert.AreEqual(accessibilityLevel, @interface.AccessibilityLevel);
        }
예제 #22
0
        public void TestIsGenericFlag_FalseWhenSetNull()
        {
            // Arrange
            string      interfaceName   = "IInterface";
            string      genericTypeName = "T";
            SGInterface @interface      = new SGInterface(interfaceName).WithGenericTypeNames(genericTypeName);

            // Act
            @interface.GenericTypeNames = null;

            // Assert
            Assert.IsFalse(@interface.IsGeneric);
        }
예제 #23
0
        public void TestAccessibilityLevelSet_PropertyInitializer()
        {
            // Arrange
            string interfaceName = "IInterface";

            // Act
            SGInterface @interface = new SGInterface(interfaceName)
            {
                AccessibilityLevel = SGAccessibilityLevel.Public
            };

            // Assert
            Assert.AreEqual(SGAccessibilityLevel.Public, @interface.AccessibilityLevel);
        }
예제 #24
0
        public void TestAddAttributes_FluentAPI()
        {
            // Arrange
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(interfaceName);
            string      attr1Name     = "Attr1";
            string      attr2Name     = "Attr2";
            SGAttribute attr1         = new SGAttribute(attr1Name);
            SGAttribute attr2         = new SGAttribute(attr2Name);

            // Act
            @interface = @interface.WithAttributes(attr1, attr2);

            // Assert
            Assert.IsTrue(@interface.Attributes.ContainsAll(attr1, attr2));
        }
예제 #25
0
        public void TestAddMethodSignatures_FluentAPI()
        {
            // Arrange
            string            interfaceName = "IInterface";
            string            methodName1   = "Method1";
            string            methodName2   = "Method2";
            SGInterface       @interface    = new SGInterface(interfaceName);
            SGMethodSignature method1       = new SGMethodSignature(methodName1);
            SGMethodSignature method2       = new SGMethodSignature(methodName2);

            // Act
            @interface = @interface.WithMethodSignatures(method1, method2);

            // Assert
            Assert.IsTrue(@interface.MethodSignatures.ContainsAll(method1, method2));
        }
예제 #26
0
        public void TestAddingMultipleInterfaces_FluentAPI()
        {
            // Arrange
            string      namespaceName = "SlnGen";
            string      interfaceName = "IInterface";
            SGInterface @interface    = new SGInterface(interfaceName);
            SGInterface interface2    = new SGInterface(interfaceName);

            // Act
            SGNamespace @namespace = new SGNamespace(namespaceName).WithInterfaces(@interface, interface2);

            // Assert
            Assert.IsTrue(@namespace.Interfaces.ContainsAll(new List <SGInterface>
            {
                @interface,
                interface2
            }));
        }
예제 #27
0
        public void TestAddInterfaceImplementation_AsString__PropertyInitializer()
        {
            // Arrange
            string interfaceName         = "IInterface";
            string implementedInterface1 = "IImp";
            string implementedInterface2 = "IImp2";

            // Act
            SGInterface @interface = new SGInterface(interfaceName)
            {
                InterfaceImplementations =
                {
                    implementedInterface1,
                    implementedInterface2
                }
            };

            // Assert
            Assert.IsTrue(@interface.InterfaceImplementations.ContainsAll(implementedInterface1, implementedInterface2));
        }
예제 #28
0
        public void TestAddGeneric_PropertyInitializer()
        {
            // Arrange
            string interfaceName    = "IInterface";
            string genericTypeName  = "T";
            string genericTypeName2 = "U";

            // Act
            SGInterface @interface = new SGInterface(interfaceName)
            {
                GenericTypeNames =
                {
                    genericTypeName,
                    genericTypeName2
                }
            };

            // Assert
            Assert.IsTrue(@interface.GenericTypeNames.ContainsAll(genericTypeName, genericTypeName2));
        }
예제 #29
0
        public void TestAddAttributes_PropertyInitializer()
        {
            // Arrange
            string      interfaceName = "IInterface";
            string      attr1Name     = "Attr1";
            string      attr2Name     = "Attr2";
            SGAttribute attr1         = new SGAttribute(attr1Name);
            SGAttribute attr2         = new SGAttribute(attr2Name);

            // Act
            SGInterface @interface = new SGInterface(interfaceName)
            {
                Attributes =
                {
                    attr1,
                    attr2
                }
            };

            // Assert
            Assert.IsTrue(@interface.Attributes.ContainsAll(attr1, attr2));
        }
예제 #30
0
        public void TestAddMethodSignatures_PropertyInitializer()
        {
            // Arrange
            string            interfaceName = "IInterface";
            string            methodName1   = "Method1";
            string            methodName2   = "Method2";
            SGMethodSignature method1       = new SGMethodSignature(methodName1);
            SGMethodSignature method2       = new SGMethodSignature(methodName2);

            // Act
            SGInterface @interface = new SGInterface(interfaceName)
            {
                MethodSignatures =
                {
                    method1,
                    method2
                }
            };

            // Assert
            Assert.IsTrue(@interface.MethodSignatures.ContainsAll(method1, method2));
        }