<commit_before>﻿using System;
using System.ComponentModel;
using System.Linq;
using Cuemon.Extensions.Xunit;
using Xunit;
using Xunit.Abstractions;

namespace Cuemon.Reflection
{
    public class AssemblyDecoratorExtensionsTest : Test
    {
        public AssemblyDecoratorExtensionsTest(ITestOutputHelper output = null) : base(output)
        {
        }

        [Fact]
        public void IsDebugBuild_ShouldBeTrueForDebugOrFalseForRelease()
        {
#if RELEASE
            Assert.False(Decorator.Enclose(this.GetType().Assembly).IsDebugBuild());
#else
            Assert.True(Decorator.Enclose(this.GetType().Assembly).IsDebugBuild());
#endif
        }

        [Fact]
        public void GetTypes_ShouldReturnAllTypesFromCuemonCore()
        {
            var a = typeof(Disposable).Assembly;

            var allTypes = Decorator.Enclose(a).GetTypes();
            var disposableTypes = Decorator.Enclose(a).GetTypes(typeFilter: typeof(Disposable));
            var configurationTypes = Decorator.Enclose(a).GetTypes($"{nameof(Cuemon)}.{nameof(Configuration)}");

            var allTypesCount = Decorator.Enclose(allTypes).Inner.Count();
            var disposableTypesCount = Decorator.Enclose(disposableTypes).Inner.Count();
            var configurationTypesCount = Decorator.Enclose(configurationTypes).Inner.Count();

            Assert.Equal(528, allTypesCount);
            Assert.Equal(7, disposableTypesCount);
            Assert.Equal(2, configurationTypesCount);
        }

        [Fact]
        public void GetAssemblyVersion_ShouldReturnAssemblyVersion()
        {
            var a = typeof(Disposable).Assembly;
            var v = Decorator.Enclose(a).GetAssemblyVersion();
            Assert.Equal("6.0.0.0", v.ToString());
            Assert.True(v.HasAlphanumericVersion);
            Assert.False(v.IsSemanticVersion());
        }

        [Fact]
        public void GetFileVersion_ShouldReturnFileVersion()
        {
            var a = typeof(Disposable).Assembly;
            var v = Decorator.Enclose(a).GetFileVersion();
            Assert.False(v.IsSemanticVersion());
            Assert.True(v.HasAlphanumericVersion);
            Assert.Equal("6.0.0", v.ToString());
        }

        [Fact]
        public void GetProductVersion_ShouldReturnProductVersion()
        {
            var a = typeof(Disposable).Assembly;
            var v = Decorator.Enclose(a).GetProductVersion();
            Assert.True(v.IsSemanticVersion());
            Assert.True(v.HasAlphanumericVersion);<commit_msg>CI builds messes with our unit test.<commit_after>﻿using System;
using System.ComponentModel;
using System.Linq;
using Cuemon.Extensions.Xunit;
using Xunit;
using Xunit.Abstractions;

namespace Cuemon.Reflection
{
    public class AssemblyDecoratorExtensionsTest : Test
    {
        public AssemblyDecoratorExtensionsTest(ITestOutputHelper output = null) : base(output)
        {
        }

        [Fact]
        public void IsDebugBuild_ShouldBeTrueForDebugOrFalseForRelease()
        {
#if RELEASE
            Assert.False(Decorator.Enclose(this.GetType().Assembly).IsDebugBuild());
#else
            Assert.True(Decorator.Enclose(this.GetType().Assembly).IsDebugBuild());
#endif
        }

        [Fact]
        public void GetTypes_ShouldReturnAllTypesFromCuemonCore()
        {
            var a = typeof(Disposable).Assembly;

            var allTypes = Decorator.Enclose(a).GetTypes();
            var disposableTypes = Decorator.Enclose(a).GetTypes(typeFilter: typeof(Disposable));
            var configurationTypes = Decorator.Enclose(a).GetTypes($"{nameof(Cuemon)}.{nameof(Configuration)}");

            var allTypesCount = Decorator.Enclose(allTypes).Inner.Count();
            var disposableTypesCount = Decorator.Enclose(disposableTypes).Inner.Count();
            var configurationTypesCount = Decorator.Enclose(configurationTypes).Inner.Count();

            Assert.InRange(allTypesCount, 525, 530); // range because of tooling on CI adding dynamic types
            Assert.Equal(7, disposableTypesCount);
            Assert.Equal(2, configurationTypesCount);
        }

        [Fact]
        public void GetAssemblyVersion_ShouldReturnAssemblyVersion()
        {
            var a = typeof(Disposable).Assembly;
            var v = Decorator.Enclose(a).GetAssemblyVersion();
            Assert.Equal("6.0.0.0", v.ToString());
            Assert.True(v.HasAlphanumericVersion);
            Assert.False(v.IsSemanticVersion());
        }

        [Fact]
        public void GetFileVersion_ShouldReturnFileVersion()
        {
            var a = typeof(Disposable).Assembly;
            var v = Decorator.Enclose(a).GetFileVersion();
            Assert.False(v.IsSemanticVersion());
            Assert.True(v.HasAlphanumericVersion);
            Assert.Equal("6.0.0", v.ToString());
        }

        [Fact]
        public void GetProductVersion_ShouldReturnProductVersion()
        {
            var a = typeof(Disposable).Assembly;
            var v = Decorator.Enclose(a).GetProductVersion();
            Assert.True(v.IsSemanticVersion());
            Assert.True(v.HasAlphanumericVersion);
{'fraction_non_alphanumeric': 0.10694147384794866, 'fraction_numerical': 0.00524985417071748, 'mean_word_length': 2.5997200839748076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '533794', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1391, 'n_words': 225}