﻿//-----------------------------------------------------------------------------
// FILE:	    Test_Schema.cs
// CONTRIBUTOR: Jeff Lill
// COPYRIGHT:	Copyright (c) 2005-2021 by neonFORGE LLC.  All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Neon.Common;
using Neon.Identity;
using Neon.Xunit;
using Neon.Xunit.YugaByte;

using Npgsql;
using Xunit;

namespace TestIdentity
{
    [Trait(TestTrait.Category, TestArea.NeonIdentity)]
    [Collection(TestCollection.NonParallel)]
    [CollectionDefinition(TestCollection.NonParallel, DisableParallelization = true)]
    public class Test_Schema : IClassFixture<YugaByteFixture>
    {
        private const string dbName      = "identity";
        private const string stsUser     = "sts";
        private const string stsPassword = "password";

        private YugaByteFixture     fixture;
        private NpgsqlConnection    identityDb;

        public Test_Schema(YugaByteFixture fixture)
        {
            TestHelper.ResetDocker(this.GetType());

            fixture.Start();

            this.fixture    = fixture;
            this.identityDb = fixture.PostgresConnection;
        }

        [Fact]
        public async Task CreateDatabase()
        {
            await IdentityHelper.InitializeDatabaseAsync(identityDb.ConnectionString, dbName, stsUser, stsPassword);
        }
    }
}
