<commit_before>// Copyright (c) <NAME>, 2012-2018. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.Extensions.Logging;
using Shouldly;
using Xunit;
using Xunit.Abstractions;

namespace MartinCostello.SqlLocalDb
{
    public class SqlLocalDbApiTests
    {
        private readonly ILoggerFactory _loggerFactory;

        public SqlLocalDbApiTests(ITestOutputHelper outputHelper)
        {
            _loggerFactory = outputHelper.AsLoggerFactory();
        }

        [Fact]
        public void Constructor_Validates_Parameters()
        {
            // Arrange
            var options = new SqlLocalDbOptions();

            Assert.Throws<ArgumentNullException>("options", () => new SqlLocalDbApi(null, _loggerFactory));
            Assert.Throws<ArgumentNullException>("loggerFactory", () => new SqlLocalDbApi(null));
            Assert.Throws<ArgumentNullException>("loggerFactory", () => new SqlLocalDbApi(options, null));
        }

        [WindowsOnlyFact]
        public void Constructor_Initializes_Instance()
        {
            // Arrange
            var options = new SqlLocalDbOptions()
            {
                AutomaticallyDeleteInstanceFiles = true,
                Language = CultureInfo.GetCultureInfo("de-DE"),
                NativeApiOverrideVersion = "11.0",
                StopOptions = StopInstanceOptions.NoWait,
                StopTimeout = TimeSpan.FromSeconds(30),
            };

            using (var actual = new SqlLocalDbApi(options, _loggerFactory))
            {
                actual.AutomaticallyDeleteInstanceFiles.ShouldBe(options.AutomaticallyDeleteInstanceFiles);
                actual.DefaultInstanceName.ShouldNotBeNull();
                actual.LanguageId.ShouldBeGreaterThan(0);
                actual.LatestVersion.ShouldNotBeNull();
                actual.LoggerFactory.ShouldNotBeNull();
                actual.StopOptions.ShouldBe(options.StopOptions);
                actual.StopTimeout.ShouldBe(options.StopTimeout);
                actual.Versions.ShouldNotBeNull();
                actual.Versions.ShouldNotBeEmpty();
                actual.Versions.ShouldBeUnique();
            }
        }

        [WindowsOnlyFact]
        public void Can_Get_Instances_From_Names()
        {
            // Arrange
            using (var api = new SqlLocalDbApi(_loggerFactory))
            {
                IReadOnlyList<string> names = api.GetInstanceNames();

                foreach (string name in names)
                {
                    // Act
                    ISqlLocalDbInstanceInfo info = api.GetInstanceInfo(name);

                    // Assert
                    info.ShouldNotBeNull();
                }

                // Arrange
                string instanceName = Guid.NewGuid().ToString();

                // Act
                bool actual = api.InstanceExists(instanceName);

                // Assert
                actual.ShouldBeFalse();
            }
        }

        [WindowsOnlyFact]
        public void Can_Test_Whether_Instances_Exist()
        {
            // Arrange
            using (var api = new SqlLocalDbApi(_loggerFactory))
            {
                // Arrange
                string instanceName = api.DefaultInstanceName;

                // Act
                bool actual = api.InstanceExists(instanceName);

                // Assert
                actual.ShouldBeTrue();

                // Arrange
                instanceName = Guid.NewGuid().ToString();

                // Act
                actual = api.InstanceExists(instanceName);

                // Assert
                actual.ShouldBeFalse();
            }
        }
    }<commit_msg>Fix test broken in AppVeyor<commit_after>// Copyright (c) <NAME>, 2012-2018. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.Extensions.Logging;
using Shouldly;
using Xunit;
using Xunit.Abstractions;

namespace MartinCostello.SqlLocalDb
{
    public class SqlLocalDbApiTests
    {
        private readonly ILoggerFactory _loggerFactory;

        public SqlLocalDbApiTests(ITestOutputHelper outputHelper)
        {
            _loggerFactory = outputHelper.AsLoggerFactory();
        }

        [Fact]
        public void Constructor_Validates_Parameters()
        {
            // Arrange
            var options = new SqlLocalDbOptions();

            Assert.Throws<ArgumentNullException>("options", () => new SqlLocalDbApi(null, _loggerFactory));
            Assert.Throws<ArgumentNullException>("loggerFactory", () => new SqlLocalDbApi(null));
            Assert.Throws<ArgumentNullException>("loggerFactory", () => new SqlLocalDbApi(options, null));
        }

        [WindowsOnlyFact]
        public void Constructor_Initializes_Instance()
        {
            // Arrange
            var options = new SqlLocalDbOptions()
            {
                AutomaticallyDeleteInstanceFiles = true,
                Language = CultureInfo.GetCultureInfo("de-DE"),
                NativeApiOverrideVersion = "11.0",
                StopOptions = StopInstanceOptions.NoWait,
                StopTimeout = TimeSpan.FromSeconds(30),
            };

            using (var actual = new SqlLocalDbApi(options, _loggerFactory))
            {
                actual.AutomaticallyDeleteInstanceFiles.ShouldBe(options.AutomaticallyDeleteInstanceFiles);
                actual.DefaultInstanceName.ShouldNotBeNull();
                actual.LanguageId.ShouldBeGreaterThan(0);
                actual.LatestVersion.ShouldNotBeNull();
                actual.LoggerFactory.ShouldNotBeNull();
                actual.StopOptions.ShouldBe(options.StopOptions);
                actual.StopTimeout.ShouldBe(options.StopTimeout);
                actual.Versions.ShouldNotBeNull();
                actual.Versions.ShouldNotBeEmpty();
                actual.Versions.ShouldBeUnique();
            }
        }

        [WindowsOnlyFact]
        public void Can_Get_Instances_From_Names()
        {
            // Arrange
            using (var api = new SqlLocalDbApi(_loggerFactory))
            {
                IReadOnlyList<string> names = api.GetInstanceNames();

                foreach (string name in names)
                {
                    // Act
                    ISqlLocalDbInstanceInfo info = api.GetInstanceInfo(name);

                    // Assert
                    info.ShouldNotBeNull();
                }

                // Arrange
                string instanceName = Guid.NewGuid().ToString();

                // Act
                bool actual = api.InstanceExists(instanceName);

                // Assert
                actual.ShouldBeFalse();
            }
        }

        [WindowsOnlyFact]
        public void Can_Test_Whether_Instances_Exist()
        {
            // Arrange
            using (var api = new SqlLocalDbApi(_loggerFactory))
            {
                // Start the default instance to ensure it exists
                api.StartInstance(api.DefaultInstanceName);

                try
                {
                    // Arrange
                    string instanceName = api.DefaultInstanceName;

                    // Act
                    bool actual = api.InstanceExists(instanceName);

                    // Assert
                    actual.ShouldBeTrue();

                    // Arrange
                    instanceName = Guid.NewGuid().ToString();

                    // Act
                    actual = api.InstanceExists(instanceName);

                    // Assert
                    actual.ShouldBeFalse();
                }
                finally
                {
                    api.StopInstance(api.DefaultInstanceName);
                }
            }
        }
    }
{'fraction_non_alphanumeric': 0.08138957816377171, 'fraction_numerical': 0.003970223325062035, 'mean_word_length': 1.592795110968157, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4323168', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1818, 'n_words': 358}