<commit_before>﻿using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using KuroganeHammer.Data.Api.Models;
using NUnit.Framework;

namespace KuroganeHammer.Data.Api.Tests.Smoke
{
    [TestFixture]
    public class CharacterAttributeSmokeTest : BaseSmokeTest
    {
        private List<CharacterAttribute> _attributes;

        [SetUp]
        public override void SetUp()
        {
            base.SetUp();
            _attributes = LoggedInBasicClient.GetAsync(Baseuri + CharacterAttributeRoute).Result.Content.ReadAsAsync<List<CharacterAttribute>>().Result;
        }

        [Test]
        public void ShouldGetAllSmashAttributeTypes()
        {
            CollectionAssert.AllItemsAreNotNull(_attributes);
            CollectionAssert.AllItemsAreUnique(_attributes);
        }

        [Test]
        public async Task ShouldGetSmashAttributeType()
        {
            var result = await LoggedInBasicClient.GetAsync(Baseuri + CharacterAttributeRoute + "/" + _attributes[0].Id);

            Assert.IsTrue(result.IsSuccessStatusCode);

            var attributeType = result.Content.ReadAsAsync<CharacterAttribute>().Result;
            Assert.That(attributeType != null);
            Assert.That(attributeType.Name.Length > 0);
        }

        [Test]
        public async Task ShouldNotGetAllSmashAttributeTypesDueToNoAuth()
        {
            var result = await AnonymousClient.GetAsync(Baseuri + CharacterAttributeRoute);
            Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
        }
    }
}<commit_msg>- Added test to get all characterattributes of a specific smashattributetype<commit_after>﻿using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using KuroganeHammer.Data.Api.DTOs;
using KuroganeHammer.Data.Api.Models;
using KuroganeHammer.Data.Api.Tests.Asserts;
using Newtonsoft.Json;
using NUnit.Framework;

namespace KuroganeHammer.Data.Api.Tests.Smoke
{
    [TestFixture]
    public class CharacterAttributeSmokeTest : BaseSmokeTest
    {
        private List<CharacterAttribute> _attributes;

        [SetUp]
        public override void SetUp()
        {
            base.SetUp();
            _attributes = LoggedInBasicClient.GetAsync(Baseuri + CharacterAttributeRoute).Result.Content.ReadAsAsync<List<CharacterAttribute>>().Result;
        }

        [Test]
        public void ShouldGetAllSmashAttributeTypes()
        {
            CollectionAssert.AllItemsAreNotNull(_attributes);
            CollectionAssert.AllItemsAreUnique(_attributes);
            CollectionPropertyAssert.AllPropertiesNotNullInCollection(_attributes, "SmashAttributeType");
        }

        [Test]
        public async Task ShouldGetCharacterAttribute()
        {
            var result = await LoggedInBasicClient.GetAsync(Baseuri + CharacterAttributeRoute + "/" + _attributes[0].Id);

            Assert.IsTrue(result.IsSuccessStatusCode);

            var attributeType = result.Content.ReadAsAsync<CharacterAttribute>().Result;
            Assert.That(attributeType != null);
            Assert.That(attributeType.Name.Length > 0);
        }

        [Test]
        public async Task ShouldGetAllCharacterAttributesofSmashAttributeType()
        {
            var attributeTypes =
                LoggedInBasicClient.GetAsync(Baseuri + SmashAttributeTypeRoute)
                    .Result.Content.ReadAsAsync<List<SmashAttributeType>>()
                    .Result;

            var result =
                await
                    LoggedInBasicClient.GetAsync(Baseuri + SmashAttributeTypeRoute + "/" + attributeTypes[3].Id + "/" +
                                                 "characterattributes");

            Assert.IsTrue(result.IsSuccessStatusCode);

            var json = await result.Content.ReadAsStringAsync();
            var characterAttributeRows = JsonConvert.DeserializeObject<List<CharacterAttributeRowDto>>(json);
            //var characterAttributeRows = await result.Content.ReadAsAsync<List<CharacterAttributeRowDto>>();

            CollectionAssert.AllItemsAreNotNull(characterAttributeRows);
            CollectionAssert.AllItemsAreUnique(characterAttributeRows);
        }

        [Test]
        public async Task ShouldNotGetAllCharacterAttributesDueToNoAuth()
        {
            var result = await AnonymousClient.GetAsync(Baseuri + CharacterAttributeRoute);
            Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
        }
    }
}
{'fraction_non_alphanumeric': 0.08573312816003517, 'fraction_numerical': 0.0010991426687183997, 'mean_word_length': 2.705211726384365, 'pattern_counts': {'":': 0, '<': 17, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '21466', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1140, 'n_words': 186}