<commit_before>﻿using System;
using System.Diagnostics;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Facepunch.Steamworks.Test
{
    [TestClass]
    [DeploymentItem( Config.LibraryName + ".dll" )]
    [DeploymentItem( "steam_appid.txt" )]
    public partial class Client
    {
        [TestMethod]
        public void Init()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                Assert.IsTrue( client.IsValid );
            }
        }

        [TestMethod]
        public void Init_10000()
        {
            for ( int i = 0; i < 50; i++ )
            {
                using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
                {
                    Assert.IsTrue( client.IsValid );
                }

                GC.Collect();
            }
        }

        [TestMethod]
        public void Name()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                var username = client.Username;
                Console.WriteLine( username );
                Assert.IsTrue( client.IsValid );
                Assert.IsNotNull( username );
            }
        }

        [TestMethod]
        public void SteamId()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                var steamid = client.SteamId;
                Console.WriteLine( steamid );
                Assert.IsTrue( client.IsValid );
                Assert.AreNotEqual( 0, steamid );
            }
        }

        [TestMethod]
        public void AuthSessionTicket()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                var ticket = client.Auth.GetAuthSessionTicket();

                Assert.IsTrue( ticket != null );
                Assert.IsTrue( ticket.Handle != 0 );
                Assert.IsTrue( ticket.Data.Length > 0 );

                ticket.Cancel();

                Assert.IsTrue( ticket.Handle == 0 );
            }
        }

        [TestMethod]
        public void VoiceOptimalSampleRate()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                var rate = client.Voice.OptimalSampleRate;
                Assert.AreNotEqual( rate, 0 );
            }
        }

        [TestMethod]
        public void Update()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                for( int i=0; i<32; i++ )
                {
                    client.Update();
                    System.Threading.Thread.Sleep( 10 );
                }
            }
        }

        static MemoryStream decompressStream = new MemoryStream();

        [TestMethod]
        public void GetVoice()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                int unCompressed = 0;
                int compressed = 0;

                client.Voice.OnCompressedData = ( ptr, length ) =><commit_msg>Sensible test<commit_after>﻿using System;
using System.Diagnostics;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Facepunch.Steamworks.Test
{
    [TestClass]
    [DeploymentItem( Config.LibraryName + ".dll" )]
    [DeploymentItem( "steam_appid.txt" )]
    public partial class Client
    {
        [TestMethod]
        public void Init()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                Assert.IsTrue( client.IsValid );
            }
        }

        [TestMethod]
        public void Init_50()
        {
            for ( int i = 0; i < 50; i++ )
            {
                using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
                {
                    Assert.IsTrue( client.IsValid );
                }

                GC.Collect();
            }
        }

        [TestMethod]
        public void Name()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                var username = client.Username;
                Console.WriteLine( username );
                Assert.IsTrue( client.IsValid );
                Assert.IsNotNull( username );
            }
        }

        [TestMethod]
        public void SteamId()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                var steamid = client.SteamId;
                Console.WriteLine( steamid );
                Assert.IsTrue( client.IsValid );
                Assert.AreNotEqual( 0, steamid );
            }
        }

        [TestMethod]
        public void AuthSessionTicket()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                var ticket = client.Auth.GetAuthSessionTicket();

                Assert.IsTrue( ticket != null );
                Assert.IsTrue( ticket.Handle != 0 );
                Assert.IsTrue( ticket.Data.Length > 0 );

                ticket.Cancel();

                Assert.IsTrue( ticket.Handle == 0 );
            }
        }

        [TestMethod]
        public void VoiceOptimalSampleRate()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                var rate = client.Voice.OptimalSampleRate;
                Assert.AreNotEqual( rate, 0 );
            }
        }

        [TestMethod]
        public void Update()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                for( int i=0; i<1024; i++ )
                {
                    client.Update();
                }
            }
        }

        static MemoryStream decompressStream = new MemoryStream();

        [TestMethod]
        public void GetVoice()
        {
            using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
            {
                int unCompressed = 0;
                int compressed = 0;

                client.Voice.OnCompressedData = ( ptr, length ) =>
{'fraction_non_alphanumeric': 0.0930756843800322, 'fraction_numerical': 0.0214170692431562, 'mean_word_length': 1.2406204906204905, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6259529', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1599, 'n_words': 349}