public void Verify_Try_Bump(ServiceMode mode, string givenSource
                                    , string expectedSource, bool expectedTrySuccess
                                    , IBumpVersionDescriptor descriptor)
        {
            // TODO: TBD: split the lines here approaching the test? or within the test itself?
            IEnumerable <string> SplitLines(string s = null)
            => (s ?? Empty).Replace("\r\n", "\n").Split('\n');

            string CombineLines(IEnumerable <string> lines)
            => Join("\r\n", lines);

            // TODO: TBD: this is it, I think, in a nutshell; notwithstanding nuances...
            Assert.NotNull(descriptor);
            Assert.NotNull(descriptor.VersionProviderTemplates);
            Assert.Collection(descriptor.VersionProviderTemplates
                              , p => { Assert.NotNull(p); }
                              , p => { Assert.NotNull(p); }
                              , p => { Assert.NotNull(p); }
                              , p => { Assert.NotNull(p); }
                              , p => { Assert.NotNull(p); }
                              );
            var service          = CreateServiceFixture(mode, descriptor);
            var givenLines       = SplitLines(givenSource).ToArray();
            var actualTrySuccess = service.TryBumpVersion(givenLines, out var actualLines);

            Assert.Equal(expectedTrySuccess, actualTrySuccess);
            var actualSource = CombineLines(actualLines);

            Assert.Equal(expectedSource, actualSource);
        }
        /// <summary>
        /// Returns a Created Fixture. Should not throw any exceptions, but we do not need to test
        /// for this explicitly. Running successfully through passing is sufficient evidence along
        /// these lines.
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="descriptor"></param>
        /// <param name="verify"></param>
        /// <returns></returns>
        internal static IAssemblyInfoBumpVersionService CreateServiceFixture(ServiceMode mode
                                                                             , IBumpVersionDescriptor descriptor = null
                                                                             , Action <IAssemblyInfoBumpVersionService> verify = null)
        {
            var serviceFixture = new AssemblyInfoBumpVersionServiceFixture <T>(descriptor)
            {
                Mode = mode
            };

            VerifyFixture(serviceFixture, mode);

            verify?.Invoke(serviceFixture);

            return(serviceFixture);
        }
Example #3
0
        /// <summary>
        /// Returns the <see cref="IProjectBasedBumpVersionService"/> corresponding with the
        /// <paramref name="descriptor"/>.
        /// </summary>
        /// <param name="descriptor"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public static IProjectBasedBumpVersionService MakeProjectBasedBumpVersionService(
            this IBumpVersionDescriptor descriptor, TaskLoggingHelper log = null)
        {
            IEnumerable <VersionKind> GetKinds()
            {
                yield return(VersionKind.Version);

                yield return(AssemblyVersion);

                yield return(FileVersion);

                yield return(InformationalVersion);

                yield return(PackageVersion);
            }

            return(GetKinds().Contains(descriptor.Kind)
                ? new ProjectBasedBumpVersionService(descriptor)
            {
                Log = log
            }
                : null);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="descriptor"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public static IAssemblyInfoBumpVersionService MakeAssemblyInfoBumpVersionService(
            this IBumpVersionDescriptor descriptor, TaskLoggingHelper log = null)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (descriptor.Kind)
            {
            case AssemblyVersion:

#if TASK_LOGGING_HELPER_DIAGNOSTICS
                log?.LogWarning($"Yielding '{typeof(AssemblyVersionAttribute).FullName}' bump version service.");
#endif

                return(new AssemblyInfoBumpVersionService <AssemblyVersionAttribute>(descriptor));

            case AssemblyFileVersion:

#if TASK_LOGGING_HELPER_DIAGNOSTICS
                log?.LogWarning($"Yielding '{typeof(AssemblyFileVersionAttribute).FullName}' bump version service.");
#endif

                return(new AssemblyInfoBumpVersionService <AssemblyFileVersionAttribute>(descriptor));

            case AssemblyInformationalVersion:

#if TASK_LOGGING_HELPER_DIAGNOSTICS
                log?.LogWarning($"Yielding '{typeof(AssemblyInformationalVersionAttribute).FullName}' bump version service.");
#endif

                return(new AssemblyInfoBumpVersionService <AssemblyInformationalVersionAttribute>(descriptor));
            }

#if TASK_LOGGING_HELPER_DIAGNOSTICS
            log?.LogWarning($"Did not yield bump version service for kind '{descriptor.Kind}'");
#endif

            return(null);
        }
 internal AssemblyInfoBumpVersionServiceFixture(IBumpVersionDescriptor descriptor)
     : base(descriptor)
 {
 }
Example #6
0
 protected AssemblyInfoBumpVersionService(IBumpVersionDescriptor descriptor)
     : base(descriptor)
 {
 }
 /// <summary>
 /// Protected Constructor.
 /// </summary>
 /// <param name="descriptor"></param>
 protected BumpVersionServiceBase(IBumpVersionDescriptor descriptor)
 {
     Descriptor = descriptor;
 }
 /// <summary>
 /// Protected Constructor.
 /// </summary>
 /// <param name="descriptor"></param>
 protected BumpResult(IBumpVersionDescriptor descriptor)
 {
     Descriptor = descriptor;
 }
 /// <summary>
 /// Internal Constructor.
 /// </summary>
 /// <param name="descriptor"></param>
 /// <inheritdoc />
 internal AssemblyInfoBumpResult(IBumpVersionDescriptor descriptor)
     : base(descriptor)
 {
 }
Example #10
0
 /// <summary>
 /// Internal Constructor
 /// </summary>
 /// <param name="descriptor"></param>
 /// <inheritdoc />
 internal ProjectBumpResult(IBumpVersionDescriptor descriptor)
     : base(descriptor)
 {
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="descriptor"></param>
 /// <inheritdoc />
 public ProjectBasedBumpVersionService(IBumpVersionDescriptor descriptor)
     : base(descriptor)
 {
 }
Example #12
0
 /// <summary>
 /// Protected Constructor.
 /// </summary>
 /// <param name="descriptor"></param>
 internal BumpResultCalculator(IBumpVersionDescriptor descriptor)
 {
     Descriptor = descriptor;
 }