Exemplo n.º 1
0
        public void WhenCreateFromClass_NameIsSetToTypeNameReturnedByTypeResolver()
        {
            var classResolvedType = this.SetupTypeResolverFor <ClassWithoutAttribute>();

            var @class = TsClass.CreateFrom <ClassWithoutAttribute>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Same(classResolvedType, @class.Name);
        }
Exemplo n.º 2
0
        public void WhenCreateFromClassWitoutInterfaces_InterfacesCollectionIsEmpty()
        {
            var classResolvedType = this.SetupTypeResolverFor <BaseClass>();

            var @class = TsClass.CreateFrom <DerivedClass>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Empty(@class.Interfaces);
        }
Exemplo n.º 3
0
        public void WhenCreateFromClassWithoutSpecificBaseClass_BaseTypeIsNull()
        {
            var baseClassResolvedType   = this.SetupTypeResolverFor <BaseClass>();
            var objectClassResolvedType = this.SetupTypeResolverFor <object>();

            var @class = TsClass.CreateFrom <BaseClass>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Null(@class.BaseType);
        }
Exemplo n.º 4
0
        public void WhenCreateFromClassWithBaseClass_BaseTypeIsSetToTypeNameReturnedByTypeResolver()
        {
            var classResolvedType     = this.SetupTypeResolverFor <DerivedClass>();
            var baseClassResolvedType = this.SetupTypeResolverFor <BaseClass>();

            var @class = TsClass.CreateFrom <DerivedClass>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Same(baseClassResolvedType, @class.BaseType);
        }
Exemplo n.º 5
0
        public void WhenCreateFromClassWithInterfaces_InterfacesCollectionDoesNotContainsInterfacesNotResolvedByTypeResolver()
        {
            var classResolvedType      = this.SetupTypeResolverFor <ClassWithIntefaces>();
            var interface1ResolvedType = this.SetupTypeResolverFor <IInterfaceForClassWithInterfaces>();

            var @class = TsClass.CreateFrom <ClassWithIntefaces>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Equal(1, @class.Interfaces.Count);
            Assert.Contains(interface1ResolvedType, @class.Interfaces);
        }
Exemplo n.º 6
0
        public void WhenCreateFromClassWithProperties_PropertiesCollectionContainsProperty()
        {
            this.SetupTypeResolverFor <ClassWithProperty>();
            this.SetupTypeResolverFor <int>();
            var propertyConfiguration = this.SetupConfigurationForMember <ClassWithProperty>("Property");

            var @class = TsClass.CreateFrom <ClassWithProperty>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Equal(1, @class.Properties.Count);
            Assert.Equal(propertyConfiguration.Name, @class.Properties[0].Name);
        }
Exemplo n.º 7
0
        public void WhenCreateFromClassWithoutProperties_PropertiesCollectionIsEmpty()
        {
            this.SetupTypeResolverFor <ClassWithoutProperties>();
            this.SetupTypeResolverFor <int>();
            this.SetupConfigurationForMember <ClassWithoutProperties>("Field");
            this.SetupConfigurationForMember <ClassWithoutProperties>("Constant");

            var @class = TsClass.CreateFrom <ClassWithoutProperties>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Empty(@class.Properties);
        }
Exemplo n.º 8
0
        public void WhenCreateFromClassWitInterfaces_InterfacesAreSetToTypesReturnedByTypeResolver()
        {
            var classResolvedType       = this.SetupTypeResolverFor <ClassWithIntefaces>();
            var interface1ResolvedType  = this.SetupTypeResolverFor <IInterfaceForClassWithInterfaces>();
            var interface1ResolvedType2 = this.SetupTypeResolverFor <IInterfaceForClassWithInterfaces2>();

            var @class = TsClass.CreateFrom <ClassWithIntefaces>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Equal(2, @class.Interfaces.Count);
            Assert.Contains(interface1ResolvedType, @class.Interfaces);
            Assert.Contains(interface1ResolvedType2, @class.Interfaces);
        }
Exemplo n.º 9
0
        public void WhenCreateFromClassWithProperties_PropertiesCollectionDoesNotContainPropertyFromBaseClass()
        {
            this.SetupTypeResolverFor <ClassWithProperty>();
            this.SetupTypeResolverFor <BaseClassWithProperty>();
            this.SetupTypeResolverFor <int>();
            this.SetupConfigurationForMember <ClassWithProperty>("Property");
            this.SetupConfigurationForMember <BaseClassWithProperty>("BaseProperty");

            var @class = TsClass.CreateFrom <ClassWithProperty>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.DoesNotContain(@class.Properties, p => p.Name == "BaseProperty");
        }
Exemplo n.º 10
0
        public void WhenCreateFromClassWithDerivedInterface_InterfacesCollectionDoesNotContainsBaseInterface()
        {
            var classResolvedType     = this.SetupTypeResolverFor <ClassWithDerivedInterface>();
            var interfaceResolvedType = this.SetupTypeResolverFor <IDerivedInterface>();

            this.SetupTypeResolverFor <IBaseInterface>();

            var @class = TsClass.CreateFrom <ClassWithDerivedInterface>(_typeResolverMock.Object, _configurationProviderMock.Object);

            Assert.Equal(1, @class.Interfaces.Count);
            Assert.Contains(interfaceResolvedType, @class.Interfaces);
        }