<commit_before>﻿using System.Reflection;

using NUnit.Framework;

using Orleans.CodeGeneration;
using Orleans.Concurrency;

namespace Orleankka.Features
{
    namespace Native_orleans_attributes
    {
        using Core;
        using Testing;

        [Version(22)]
        public interface ITestVersionActor : IActor {}
        public class TestVersionActor : Actor, ITestVersionActor {}

        [StatelessWorker]
        public class TestDefaultStatelessWorkerActor : Actor {}

        [StatelessWorker(4)]
        public class TestParameterizedStatelessWorkerActor : Actor {}

        [TestFixture]
        [RequiresSilo]
        public class Tests
        {
            [Test]
            public void Version_attribute()
            {
                var @interface = ActorInterface.Of<TestVersionActor>();
                var attribute = @interface.Grain.GetCustomAttribute<VersionAttribute>();
                Assert.That(attribute, Is.Not.Null);
                Assert.That(attribute.Version, Is.EqualTo(22));
            }

            [Test]
            public void StatelessWorker_attribute()
            {
                var type = ActorType.Of<TestDefaultStatelessWorkerActor>();
                var attribute = type.Grain.GetCustomAttribute<StatelessWorkerAttribute>();
                Assert.That(attribute, Is.Not.Null);
                Assert.That(attribute.MaxLocalWorkers, Is.EqualTo(new StatelessWorkerAttribute().MaxLocalWorkers));

                type = ActorType.Of<TestParameterizedStatelessWorkerActor>();
                attribute = type.Grain.GetCustomAttribute<StatelessWorkerAttribute>();
                Assert.That(attribute, Is.Not.Null);
                Assert.That(attribute.MaxLocalWorkers, Is.EqualTo(4));
            }
        }
    }
}<commit_msg>Add test for storageprovider attribute<commit_after>﻿using System;
using System.Reflection;

using NUnit.Framework;

using Orleans.CodeGeneration;
using Orleans.Concurrency;
using Orleans.Providers;

namespace Orleankka.Features
{
    namespace Native_orleans_attributes
    {
        using Core;
        using Testing;

        [Version(22)]
        public interface ITestVersionActor : IActor {}
        public class TestVersionActor : Actor, ITestVersionActor {}

        [StatelessWorker]
        public class TestDefaultStatelessWorkerActor : Actor {}

        [StatelessWorker(4)]
        public class TestParameterizedStatelessWorkerActor : Actor {}

        [StorageProvider]
        public class TestDefaultStorageProviderActor : Actor {}

        [TestFixture]
        [RequiresSilo]
        public class Tests
        {
            static TAttribute AssertHasCustomAttribute<TActor, TAttribute>() where TActor : Actor where TAttribute : Attribute => 
                AssertHasCustomAttribute<TAttribute>(ActorType.Of<TActor>().Grain);

            static TAttribute AssertHasCustomAttribute<TAttribute>(Type type) where TAttribute : Attribute
            {
                var attribute = type.GetCustomAttribute<TAttribute>();
                Assert.That(attribute, Is.Not.Null);
                return attribute;
            }

            [Test]
            public void Version_attribute()
            {
                var @interface = ActorInterface.Of<TestVersionActor>();
                var attribute = AssertHasCustomAttribute<VersionAttribute>(@interface.Grain);
                Assert.That(attribute.Version, Is.EqualTo(22));
            }

            [Test]
            public void StatelessWorker_attribute()
            {
                var attribute = AssertHasCustomAttribute<TestDefaultStatelessWorkerActor, StatelessWorkerAttribute>();
                Assert.That(attribute.MaxLocalWorkers, Is.EqualTo(new StatelessWorkerAttribute().MaxLocalWorkers));

                attribute = AssertHasCustomAttribute<TestParameterizedStatelessWorkerActor, StatelessWorkerAttribute>();
                Assert.That(attribute.MaxLocalWorkers, Is.EqualTo(4));
            }

            [Test]
            public void StorageProvider_attribute()
            {
                var attribute = AssertHasCustomAttribute<TestDefaultStorageProviderActor, StorageProviderAttribute>();
                Assert.That(attribute.ProviderName, Is.EqualTo(new StorageProviderAttribute().ProviderName));
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08163737280296023, 'fraction_numerical': 0.0027752081406105457, 'mean_word_length': 2.355314197051978, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, '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': '2766882', 'n_tokens_mistral': 1053, 'n_tokens_neox': 998, 'n_words': 196}