Esempio n. 1
0
 public static Output <Union <ChartArgsUnwrap, LocalChartArgsUnwrap> > Unwrap(this Union <ChartArgs, LocalChartArgs> options)
 {
     return(options.Match(
                v => Output.Tuple(v.ApiVersions, v.Namespace.ToNullable(), v.Values, v.Repo.ToNullable(), v.Chart, v.Version.ToNullable(), v.FetchOptions.Unwrap(), new InputList <bool?> {
         v.IncludeTestHookResources.ToNullable(), v.SkipCRDRendering.ToNullable()
     }).Apply(vs =>
              Union <ChartArgsUnwrap, LocalChartArgsUnwrap> .FromT0(
                  new ChartArgsUnwrap
     {
         ApiVersions = vs.Item1,
         Namespace = vs.Item2,
         Values = vs.Item3,
         Transformations = v.Transformations,
         ResourcePrefix = v.ResourcePrefix,
         Repo = vs.Item4,
         Chart = vs.Item5,
         Version = vs.Item6,
         FetchOptions = vs.Item7,
         IncludeTestHookResources = vs.Item8[0],
         SkipCRDRendering = vs.Item8[1]
     })),
                v => Output.Tuple(v.ApiVersions, v.IncludeTestHookResources.ToNullable(), v.SkipCRDRendering.ToNullable(), v.Namespace.ToNullable(), v.Values).Apply(vs =>
                                                                                                                                                                     Union <ChartArgsUnwrap, LocalChartArgsUnwrap> .FromT1(
                                                                                                                                                                         new LocalChartArgsUnwrap
     {
         ApiVersions = vs.Item1,
         IncludeTestHookResources = vs.Item2,
         SkipCRDRendering = vs.Item3,
         Namespace = vs.Item4,
         Values = vs.Item5,
         Transformations = v.Transformations,
         ResourcePrefix = v.ResourcePrefix,
         Path = v.Path
     }))));
 }
Esempio n. 2
0
        public Task InputUnionInitializer()
        => RunInPreview(async() =>
        {
            var sample = new SampleArgs {
                Union = "testValue"
            };
            var data = await sample.Union.ToOutput().DataTask.ConfigureAwait(false);
            Assert.Equal("testValue", data.Value);

            sample = new SampleArgs {
                Union = 123
            };
            data = await sample.Union.ToOutput().DataTask.ConfigureAwait(false);
            Assert.Equal(123, data.Value);

            sample = new SampleArgs {
                Union = Union <string, int> .FromT0("left")
            };
            data = await sample.Union.ToOutput().DataTask.ConfigureAwait(false);
            Assert.Equal("left", data.Value);

            sample = new SampleArgs {
                Union = Union <string, int> .FromT1(456)
            };
            data = await sample.Union.ToOutput().DataTask.ConfigureAwait(false);
            Assert.Equal(456, data.Value);
        });
Esempio n. 3
0
 public Task InputMapUnionInitializer()
 => RunInPreview(async() =>
 {
     var sample = new SampleArgs
     {
         Dict =
         {
             { "left",  "testValue"          },
             { "right",                  123 },
             { "t0",    Union <string, int> .FromT0("left")},
             { "t1",    Union <string, int> .FromT1(456)},
         }
     };
     var data = await sample.Dict.ToOutput().DataTask.ConfigureAwait(false);
     Assert.Equal(4, data.Value.Count);
     Assert.True(data.Value.ContainsValue("testValue"));
     Assert.True(data.Value.ContainsValue(123));
     Assert.True(data.Value.ContainsValue("left"));
     Assert.True(data.Value.ContainsValue(456));
 });
Esempio n. 4
0
 public Task InputListUnionInitializer()
 => RunInPreview(async() =>
 {
     var sample = new SampleArgs
     {
         List =
         {
             "testValue",
             123,
             Union <string,int> .FromT0("left"),
             Union <string,int> .FromT1(456),
         }
     };
     var data = await sample.List.ToOutput().DataTask.ConfigureAwait(false);
     Assert.Equal(4, data.Value.Length);
     Assert.True(data.Value.IndexOf("testValue") >= 0);
     Assert.True(data.Value.IndexOf(123) >= 0);
     Assert.True(data.Value.IndexOf("left") >= 0);
     Assert.True(data.Value.IndexOf(456) >= 0);
 });
Esempio n. 5
0
 public static Output <Union <ChartArgsUnwrap, LocalChartArgsUnwrap> > Unwrap(this Union <ChartArgs, LocalChartArgs> options)
 {
     return(options.Match(
                v => Output.Tuple(v.ApiVersions, v.Namespace.ToNullable(), v.Values, v.Repo.ToNullable(), v.Chart, v.Version.ToNullable(), v.FetchOptions.Unwrap()).Apply(vs =>
                                                                                                                                                                          Union <ChartArgsUnwrap, LocalChartArgsUnwrap> .FromT0(
                                                                                                                                                                              new ChartArgsUnwrap
     {
         ApiVersions = vs.Item1,
         Namespace = vs.Item2,
         Values = vs.Item3,
         Transformations = v.Transformations,
         ResourcePrefix = v.ResourcePrefix,
         Repo = vs.Item4,
         Chart = vs.Item5,
         Version = vs.Item6,
         FetchOptions = vs.Item7
     })),
                v => Output.Tuple(v.ApiVersions, v.Namespace.ToNullable(), v.Values).Apply(vs =>
                                                                                           Union <ChartArgsUnwrap, LocalChartArgsUnwrap> .FromT1(
                                                                                               new LocalChartArgsUnwrap
     {
         ApiVersions = vs.Item1,
         Namespace = vs.Item2,
         Values = vs.Item3,
         Transformations = v.Transformations,
         ResourcePrefix = v.ResourcePrefix,
         Path = v.Path
     }))));
 }
Esempio n. 6
0
 public static Output <Union <T0, U> > ApplyT1 <T0, T1, U>(this Output <Union <T0, T1> > union, Func <T1, Output <U> > func)
 => union.Apply(v => v.IsT1 ? func(v.AsT1).Apply(v => Union <T0, U> .FromT1(v)) : Output.Create(Union <T0, U> .FromT0(v.AsT0)));