-
-
Notifications
You must be signed in to change notification settings - Fork 986
/
Copy pathAttributesTests.cs
51 lines (41 loc) · 1.37 KB
/
AttributesTests.cs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using BenchmarkDotNet.Attributes;
using Xunit;
using Xunit.Abstractions;
namespace BenchmarkDotNet.IntegrationTests
{
public class AttributesTests : BenchmarkTestExecutor
{
public AttributesTests(ITestOutputHelper output) : base(output) { }
[Fact]
public void AttributesAreNotSealed()
{
CanExecute<ConsumingCustomAttributes>();
}
public class ConsumingCustomAttributes
{
private const int ExpectedNumber = 123;
private const string ExpectedText = "expectedTest";
[CustomParams(ExpectedNumber)]
public int Number;
public string Text;
[CustomGlobalSetup]
public void Setup()
{
Text = ExpectedText;
}
[CustomBenchmark]
public void Benchmark()
{
if (ExpectedNumber != Number || ExpectedText != Text)
throw new Exception("Custom attributes were not applied!");
}
}
private class CustomParamsAttribute : ParamsAttribute
{
public CustomParamsAttribute(params object[] values) : base(values) { }
}
private class CustomBenchmarkAttribute : BenchmarkAttribute { }
private class CustomGlobalSetupAttribute : GlobalSetupAttribute { }
}
}