-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUnitTestExceptions.cs
113 lines (103 loc) · 4.19 KB
/
UnitTestExceptions.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
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
103
104
105
106
107
108
109
110
111
112
113
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net;
using WebDAVSharp.Server.Exceptions;
namespace WebDAVTests
{
/// <summary>
/// Tests if the exceptions have the right statuscodes
/// </summary>
[TestClass]
public class UnitTestExceptions
{
/// <summary>
/// Checks if the <see cref="WebDavConflictException" /> has the statuscode 409 Conflict.
/// </summary>
[TestMethod]
public void Exception_Conflict_Test()
{
var exception = new WebDavConflictException();
Assert.AreEqual((int)HttpStatusCode.Conflict, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavForbiddenException" /> has the statuscode 403 Forbidden.
/// </summary>
[TestMethod]
public void Exception_Forbidden_Test()
{
var exception = new WebDavForbiddenException();
Assert.AreEqual((int)HttpStatusCode.Forbidden, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavInternalServerException" /> has the statuscode 500 Internal Server Error.
/// </summary>
[TestMethod]
public void Exception_InternalServer_Test()
{
var exception = new WebDavInternalServerException();
Assert.AreEqual((int)HttpStatusCode.InternalServerError, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavLengthRequiredException" /> has the statuscode 411 Length Required.
/// </summary>
[TestMethod]
public void Exception_LengthRequired_Test()
{
var exception = new WebDavLengthRequiredException();
Assert.AreEqual((int)HttpStatusCode.LengthRequired, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavMethodNotAllowedException" /> has the statuscode 405 Method Not Allowed.
/// </summary>
[TestMethod]
public void Exception_MethodNotAllowed_Test()
{
var exception = new WebDavMethodNotAllowedException();
Assert.AreEqual((int)HttpStatusCode.MethodNotAllowed, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavNotFoundException" /> has the statuscode 404 Not Found.
/// </summary>
[TestMethod]
public void Exception_NotFound_Test()
{
var exception = new WebDavNotFoundException();
Assert.AreEqual((int)HttpStatusCode.NotFound, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavNotImplementedException" /> has the statuscode 501 Not Implemented.
/// </summary>
[TestMethod]
public void Exception_NotImplemented_Test()
{
var exception = new WebDavNotImplementedException();
Assert.AreEqual((int)HttpStatusCode.NotImplemented, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavPreconditionFailedException" /> has the statuscode 412 Precondition Failed.
/// </summary>
[TestMethod]
public void Exception_PreconditionFailed_Test()
{
var exception = new WebDavPreconditionFailedException();
Assert.AreEqual((int)HttpStatusCode.PreconditionFailed, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavUnauthorizedException" /> has the statuscode 401 Unauthorized.
/// </summary>
[TestMethod]
public void Exception_Unauthorized_Test()
{
var exception = new WebDavUnauthorizedException();
Assert.AreEqual((int)HttpStatusCode.Unauthorized, exception.StatusCode);
}
/// <summary>
/// Checks if the <see cref="WebDavUnsupportedMediaTypeException" /> has the statuscode 415 Unsupported Media Type.
/// </summary>
[TestMethod]
public void Exception_UnsupportedMediaType_Test()
{
var exception = new WebDavUnsupportedMediaTypeException();
Assert.AreEqual((int)HttpStatusCode.UnsupportedMediaType, exception.StatusCode);
}
}
}