public void Configure_TestEnumsAddedTogether_BothEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator { JsConfigProxy = proxyFake }
                .WithEnumTypes(new Type[] { null })
                .WithEnumTypes(new[] { typeof(FakeTestingEnum), typeof(DifferentNamespaceEnum) })
                .Configure();

            Assert.Equal(2, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(FakeTestingEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DifferentNamespaceEnum)));
        }
        public void Configure_TestAssembly_AllEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator {JsConfigProxy = proxyFake}
                .WithAssemblies(new[] {Assembly.GetExecutingAssembly()})
                .Configure();

            Assert.Equal(3, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof (WhereTheEnumHasNoNamespace)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof (FakeTestingEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof (DifferentNamespaceEnum)));
        }
        public void Configure_FilterSpecifiedNoAssembly_OnlyExplicitEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator {
                JsConfigProxy = proxyFake
            }
            .WithEnumTypes(new[] { typeof(DateTimeKind) })
            .WithNamespaceFilter(ns => ns.StartsWith("SomeOtherNamespace"))
            .Configure();

            Assert.Equal(1, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DateTimeKind)));
        }
        public void Configure_TestEnumsAddedTogether_BothEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator {
                JsConfigProxy = proxyFake
            }
            .WithEnumTypes(new Type[] { null })
            .WithEnumTypes(new[] { typeof(FakeTestingEnum), typeof(DifferentNamespaceEnum) })
            .Configure();

            Assert.Equal(2, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(FakeTestingEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DifferentNamespaceEnum)));
        }
        public void Configure_TestAssembly_AllEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator {
                JsConfigProxy = proxyFake
            }
            .WithAssemblies(new[] { typeof(WhereTheEnumHasNoNamespace).GetTypeInfo().Assembly })
            .Configure();

            Assert.Equal(3, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(WhereTheEnumHasNoNamespace)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(FakeTestingEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DifferentNamespaceEnum)));
        }
        public void Configure_NamespaceFilteredAndExplicitEnum_BothEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator {
                JsConfigProxy = proxyFake
            }
            .WithEnumTypes(new[] { typeof(DateTimeKind) })
            .WithNamespaceFilter(ns => ns.StartsWith("SomeOtherNamespace"))
            .WithAssemblies(new[] { typeof(DifferentNamespaceEnum).GetTypeInfo().Assembly })
            .Configure();

            Assert.Equal(2, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DifferentNamespaceEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DateTimeKind)));
        }
        public void Configure_NamespaceExcludedEnumAddedExplicitly_AllEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator {JsConfigProxy = proxyFake}
                .WithEnumTypes(new[] {typeof (DateTimeKind)})
                .WithEnumTypes(new[] {typeof (FakeTestingEnum)})
                .WithAssemblies(new[] {Assembly.GetExecutingAssembly()})
                .WithNamespaceFilter(ns => ns.StartsWith("SomeOtherNamespace"))
                .Configure();

            Assert.Equal(3, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(FakeTestingEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DifferentNamespaceEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DateTimeKind)));
        }
Ejemplo n.º 8
0
        public void Configure_NamespaceExcludedEnumAddedExplicitly_AllEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator {
                JsConfigProxy = proxyFake
            }
            .WithEnumTypes(new[] { typeof(DateTimeKind) })
            .WithEnumTypes(new[] { typeof(FakeTestingEnum) })
            .WithAssemblies(new[] { Assembly.GetExecutingAssembly() })
            .WithNamespaceFilter(ns => ns.StartsWith("SomeOtherNamespace"))
            .Configure();

            Assert.Equal(3, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(FakeTestingEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DifferentNamespaceEnum)));
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DateTimeKind)));
        }
        public void Configure_FilterSpecifiedNoAssembly_OnlyExplicitEnumsConfigured()
        {
            var proxyFake = new EnumSerializerInitializerProxyFake();

            new EnumSerializerConfigurator { JsConfigProxy = proxyFake }
                .WithEnumTypes(new[] { typeof(DateTimeKind) })
                .WithNamespaceFilter(ns => ns.StartsWith("SomeOtherNamespace"))
                .Configure();

            Assert.Equal(1, proxyFake.ConfigedTypes.Count);
            Assert.True(proxyFake.ConfigedTypes.Contains(typeof(DateTimeKind)));
        }