コード例 #1
0
        public void Should_build_argument_from_property_with_method_Call()
        {
            var typeTemplate = new TypeTemplate <Employee>();

            typeTemplate.AddArgument(x => x.Company.AsJson());

            var typeTemplateModel = typeTemplate.GetModel();

            typeTemplateModel.Arguments.Single().Name.Should().Be("CompanyAsJson");
            typeTemplateModel.Arguments.Single().Assignment.Should().Be("$this.Company.AsJson()");
        }
コード例 #2
0
        public void Should_build_argument_from_property_with_datetime_coaless()
        {
            var typeTemplate = new TypeTemplate <Employee>();

            typeTemplate.AddArgument(x => (x.SomeDate ?? DateTime.MinValue));

            var typeTemplateModel = typeTemplate.GetModel();

            typeTemplateModel.Arguments.Single().Name.Should().Be("SomeDate");
            typeTemplateModel.Arguments.Single().Assignment.Should().Be("$this.SomeDate ?? DateTime.MinValue");
        }
コード例 #3
0
        public void Should_build_argument_from_property_with_null_coaless()
        {
            var typeTemplate = new TypeTemplate <Employee>();

            typeTemplate.AddArgument(x => (x.Id ?? ""));

            var typeTemplateModel = typeTemplate.GetModel();

            typeTemplateModel.Arguments.Single().Assignment.Should().Be("Id");
            typeTemplateModel.Arguments.Single().Assignment.Should().Be("$this.Id ?? \"\"");
        }
コード例 #4
0
        public void Should_build_argument_from_sub_property()
        {
            var typeTemplate = new TypeTemplate <Employee>();

            typeTemplate.AddArgument(x => x.Company.Id);

            var typeTemplateModel = typeTemplate.GetModel();

            typeTemplateModel.Arguments.Single().Name.Should().Be("CompanyId");
            typeTemplateModel.Arguments.Single().Assignment.Should().Be("$this.Company.Id");
        }
コード例 #5
0
        public void Should_build_argument_from_static_method_with_extensionMethod()
        {
            var typeTemplate = new TypeTemplate <Employee>();

            typeTemplate.AddArgument("correlationId", x => ContextExtensionMethods.GetCurrent("correlationId"));

            var typeTemplateModel = typeTemplate.GetModel();

            Console.WriteLine(typeTemplateModel.Arguments.Single().Assignment);
            typeTemplateModel.Arguments.Single().Name.Should().Be("correlationId");
            typeTemplateModel.Arguments.Single().Assignment.Should().Be("ContextExtensionMethods.GetCurrent(\"correlationId\")");
        }
コード例 #6
0
        public void Should_build_argument_from_static_method_with_indexer_property_call()
        {
            var typeTemplate = new TypeTemplate <Employee>();

            typeTemplate.AddArgument("correlationId", x => Context.Current == null ? "" : Context.Current["correlationId"]);

            var typeTemplateModel = typeTemplate.GetModel();

            Console.WriteLine(typeTemplateModel.Arguments.Single().Assignment);
            typeTemplateModel.Arguments.Single().Name.Should().Be("correlationId");
            typeTemplateModel.Arguments.Single().Assignment.Should().Be("Context.Current == null ? \"\" : Context.Current[\"correlationId\"]");
        }