public void OnlySharedTypesAreEmitted()
        {
            var res = TeeSquareWebApi.GenerateForControllers()
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void TheRequestFactoryDestructuresTheDtoIntoTheRouteOrQuery()
        {
            var res = TeeSquareWebApi.GenerateForControllers(typeof(DtoFromRouteOrQueryController))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#3
0
        public void FilterControllersAreNotEmitted()
        {
            var res = TeeSquareWebApi.GenerateForControllers(TestConstants.SimpleControllers)
                      .WithControllerFilter(c => c != typeof(FormValueController))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void NullableReferenceTypes()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .AddTypes(typeof(TypeWithNullableReference))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void OpenGenerics()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .AddTypes(typeof(Result <>), typeof(Result <int>))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void EnumAlternativeSizes()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .AddTypes(typeof(ByteEnum), typeof(LongEnum), typeof(UnsignedLongEnum))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void TheyAreIncludedInTheOutput()
        {
            var res = TeeSquareWebApi.GenerateForAssemblies(WebApiAssembly)
                      .AddTypes(typeof(NotUsedInApiTestDto))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void Enum()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .AddTypes(typeof(Title))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void ReflectMethods()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(options => { options.ReflectMethods = t => t.IsInterface; })
                      .AddTypes(typeof(ISampleApi))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void OriginalCase()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(options => { options.TypeConverter.NamingConventions.Properties = NameConvention.Original; })
                      .AddTypes(typeof(Name))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#11
0
        public void SupportedDiscriminatorTypes()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(TeeSquareUnionTypes.Configure)
                      .AddTypes(typeof(SupportedDiscriminatorTypes))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#12
0
        public void GenericUnionType()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(TeeSquareUnionTypes.Configure)
                      .AddTypes(typeof(Result <>))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#13
0
        public void EntireTree()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(TeeSquareMobx.ConfigureMobxWriter)
                      .AddTypes(typeof(Library))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res, CreateFileForActual)
            .AssertAreTheSame(Assert.Fail);
        }
        public void EnumAsStrings()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(options => { options.EnumValueTypeStrategy = EnumValueTypeStrategies.AllString; })
                      .AddTypes(typeof(Title))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#15
0
        public void NullableProperties()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(TeeSquareMobx.ConfigureMobxWriter)
                      .AddTypes(typeof(Book))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void ImportDependencies()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .AddImportedTypes(("./ReflectiveWriterTests.SmallTree", new[] { typeof(Title) }))
                      .AddTypes(typeof(Name))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#17
0
        public void LeafClass()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(TeeSquareMobx.ConfigureMobxWriter)
                      .AddTypes(typeof(Location))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#18
0
        public void OutputClassStrategy()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(options => { options.ComplexTypeStrategy = (writer, type) => writer.WriteClass(type); })
                      .AddTypes(typeof(Library))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void UnusedImportsAreOmitted()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .AddImportedTypes(("./ReflectiveWriterTests.SmallTree",
                                         new[] { typeof(Title), typeof(Book), typeof(Library) }))
                      .AddTypes(typeof(Name))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void AllRoutesAndDtosAreOutput()
        {
            var res = TeeSquareWebApi.GenerateForAssemblies(TestConstants.WebApiAssembly)
                      .Configure(options =>
            {
                options.TypeConverter = new TypeConverter((typeof(IFormFile), "File"));
            })
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void TheKindDeterminedByTheStrategyIsUsed()
        {
            var res = TeeSquareWebApi.GenerateForControllers(typeof(OtherController))
                      .Configure(options =>
            {
                options.GetParameterKindStrategy = (paramInfo, route, method) => ParameterKind.Route;
            })
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void TheyCanBeImportedFromElsewhere()
        {
            var res = TeeSquareWebApi.GenerateForControllers(typeof(TestController))
                      .Configure(options =>
            {
                options.RequestHelperTypeOption = RequestHelperTypeOptions.ImportTypes("./WhenNoControllersAreReferenced.OnlySharedTypesAreEmitted");
            })
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void NullablePropertiesAsNullUnion()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(options =>
                                 options.InterfaceWriterFactory =
                                     new InterfaceWriterFactory(OptionalFieldRendering.WithNullUnion))
                      .AddTypes(typeof(Book))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#24
0
        public void OverrideNames()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(TeeSquareMobx.ConfigureMobxWriter(new MobxOptions
            {
                EmitInstanceType = false
            }, new CustomMobxTypeConverter()))
                      .AddTypes(typeof(Library))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res, CreateFileForActual)
            .AssertAreTheSame(Assert.Fail);
        }
示例#25
0
        public void AlternativeNullableProperties()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(TeeSquareMobx.ConfigureMobxWriter(new MobxOptions()
            {
                OptionalType = "types.maybeNull({0})"
            }))
                      .AddTypes(typeof(Book))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res, CreateFileForActual)
            .AssertAreTheSame(Assert.Fail);
        }
示例#26
0
        public void TheyAreIncludedInTheOutput()
        {
            var res = TeeSquareWebApi.GenerateForControllers(TestConstants.SimpleControllers)
                      .Configure(options =>
            {
                options.TypeConverter = new TypeConverter((typeof(IFormFile), "File"));
            })
                      .AddTypes(typeof(NotUsedInApiTestDto))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#27
0
        public void DiscriminatorProperty()
        {
            var res = TeeSquareFluent.ReflectiveWriter()
                      .Configure(options =>
            {
                options.TypeConverter = new DiscriminatedUnionTypeConverter();
            })
                      .AddTypes(typeof(Circle), typeof(Square), typeof(Rectangle))
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
示例#28
0
        public void ContentBetweenBracesIsIndented()
        {
            var res = WriteToMemory(w =>
            {
                w.OpenBlock();
                w.WriteLine("let i = 0;");
                w.WriteLine("return i;");
                w.CloseBlock();
            });

            Blurk.CompareImplicitFile()
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void NullableBodyTypesAreHandledCorrectly()
        {
            var res = TeeSquareWebApi.GenerateForControllers(typeof(OtherController))
                      .Configure(options =>
            {
                options.GetParameterKindStrategy = (paramInfo, route, method) => ParameterKind.Body;
                options.GetHttpMethodAndRequestFactoryStrategy =
                    (controller, action) => (RequestInfo.Post, HttpMethod.Post);
            })
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }
        public void TheRouteDeterminedByTheStrategyIsUsed()
        {
            var res = TeeSquareWebApi.GenerateForControllers(typeof(ReturnValueAttributeController))
                      .Configure(options =>
            {
                var defaultStrategy        = options.BuildRouteStrategy;
                options.BuildRouteStrategy = (controller, action, defaultRoute) =>
                                             $"prefix/{defaultStrategy(controller, action, defaultRoute)}";
            })
                      .WriteToString();

            Blurk.CompareImplicitFile("ts")
            .To(res)
            .AssertAreTheSame(Assert.Fail);
        }