forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrinterResolutionTests.cs
More file actions
102 lines (91 loc) · 3.36 KB
/
Copy pathPrinterResolutionTests.cs
File metadata and controls
102 lines (91 loc) · 3.36 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.ComponentModel;
using Xunit;
namespace System.Drawing.Printing.Tests
{
public class PrinterResolutionTests
{
[Fact]
public void Ctor_Default()
{
var resolution = new PrinterResolution();
Assert.Equal(PrinterResolutionKind.Custom, resolution.Kind);
Assert.Equal(0, resolution.X);
Assert.Equal(0, resolution.Y);
}
[Theory]
[InlineData(int.MaxValue)]
[InlineData(1)]
[InlineData(0)]
[InlineData(-1)]
[InlineData(int.MinValue)]
public void X_Value_ReturnsExpected(int value)
{
var resolution = new PrinterResolution
{
X = value
};
Assert.Equal(value, resolution.X);
// Set same.
resolution.X = value;
Assert.Equal(value, resolution.X);
}
[Theory]
[InlineData(int.MaxValue)]
[InlineData(1)]
[InlineData(0)]
[InlineData(-1)]
[InlineData(int.MinValue)]
public void Y_Value_ReturnsExpected(int value)
{
var resolution = new PrinterResolution
{
Y = value
};
Assert.Equal(value, resolution.Y);
// Set same.
resolution.Y = value;
Assert.Equal(value, resolution.Y);
}
[Theory]
[InlineData(PrinterResolutionKind.Custom)]
[InlineData(PrinterResolutionKind.Draft)]
[InlineData(PrinterResolutionKind.High)]
[InlineData(PrinterResolutionKind.Low)]
[InlineData(PrinterResolutionKind.Medium)]
public void Kind_Set_GetReturnsExpected(PrinterResolutionKind value)
{
var resolution = new PrinterResolution
{
Kind = value
};
Assert.Equal(value, resolution.Kind);
// Set same.
resolution.Kind = value;
Assert.Equal(value, resolution.Kind);
}
[Theory]
[InlineData(PrinterResolutionKind.Custom + 1)]
[InlineData(PrinterResolutionKind.High - 1)]
public void Kind_SetInvalid_ThrowsInvalidEnumArgumentException(PrinterResolutionKind value)
{
var resolution = new PrinterResolution();
Assert.Throws<InvalidEnumArgumentException>("value", () => resolution.Kind = value);
}
public static IEnumerable<object[]> ToString_TestData()
{
yield return new object[] { new PrinterResolution(), "[PrinterResolution X=0 Y=0]" };
yield return new object[] { new PrinterResolution { X = -1, Y = -2}, "[PrinterResolution X=-1 Y=-2]" };
yield return new object[] { new PrinterResolution { Kind = PrinterResolutionKind.High }, "[PrinterResolution High]" };
yield return new object[] { new PrinterResolution { X = 1, Y = 2, Kind = PrinterResolutionKind.High }, "[PrinterResolution High]" };
}
[Theory]
[MemberData(nameof(ToString_TestData))]
public void ToString_Invoke_ReturnsExpected(PrinterResolution resolution, string expected)
{
Assert.Equal(expected, resolution.ToString());
}
}
}