Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ComAliasNameAttributeTests.cs « InteropServices « Runtime « System « tests « System.Runtime.InteropServices « src - github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4fef851968dcddeecd0b477b30af2f7aab81830b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Linq;
using System.Reflection;
using Xunit;

namespace System.Runtime.InteropServices.Tests
{
    public class ComAliasNameAttributeTests
    {
#pragma warning disable 0169
        [ComAliasName("foo")]
        private int _foo;
#pragma warning restore 0169

        [Fact]
        public void Exists()
        {
            FieldInfo field = typeof(ComAliasNameAttributeTests).GetTypeInfo().DeclaredFields.Single(f => f.Name == "_foo");
            ComAliasNameAttribute attribute = Assert.Single(field.GetCustomAttributes<ComAliasNameAttribute>(false));
            Assert.Equal("foo", attribute.Value);
        }

        [Theory]
        [InlineData(null)]
        [InlineData("")]
        [InlineData("value")]
        public void Ctor_Alias(string alias)
        {
            var attribute = new ComAliasNameAttribute(alias);
            Assert.Equal(alias, attribute.Value);
        }
    }
}