-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathModelManagerTests.cs
More file actions
44 lines (37 loc) · 1.07 KB
/
ModelManagerTests.cs
File metadata and controls
44 lines (37 loc) · 1.07 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
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JSONAPI.Core;
using JSONAPI.Tests.Models;
using System.Reflection;
namespace JSONAPI.Tests.Core
{
[TestClass]
public class ModelManagerTests
{
private class InvalidModel
{
public string Data { get; set; }
}
[TestMethod]
public void FindsIdNamedId()
{
// Arrange
var mm = new ModelManager();
// Act
PropertyInfo idprop = mm.GetIdProperty(typeof(Author));
// Assert
Assert.AreSame(typeof(Author).GetProperty("Id"), idprop);
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void DoesntFindMissingId()
{
// Arrange
var mm = new ModelManager();
// Act
PropertyInfo idprop = mm.GetIdProperty(typeof(InvalidModel));
// Assert
Assert.Fail("An InvalidOperationException should be thrown and we shouldn't get here!");
}
}
}