-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathUnitTests.cs
More file actions
48 lines (40 loc) · 1.41 KB
/
UnitTests.cs
File metadata and controls
48 lines (40 loc) · 1.41 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
using Exercise;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Execise.Tests
{
[TestClass]
public class UnitTests
{
//test the two calls to library instance return same instance
[TestMethod]
public void LibraryShouldBeSingleton()
{
var l1 = Library.GetInstance();
var l2 = Library.GetInstance();
Assert.AreSame(l1, l2);
}
//test that an book was registered successfully by checking the returned Id value is not -1
[TestMethod]
public void BookShouldRegister()
{
int value = RegistrationRepository.Register(new Book("Author", "Title", 1997, 5));
Assert.AreNotEqual<int>(-1, value);
}
//test that an customer was registered successfully by checking the returned Id value is not -1
[TestMethod]
public void CustomerShouldRegister()
{
int value = RegistrationRepository.Register(new Customer("Customer Name", "Address"));
Assert.AreNotEqual<int>(-1, value);
}
//test that a book can be borrowed
[TestMethod]
public void CanBorrowBook()
{
var book = new Book("Author", "Title", 1997, 5);
var borrowable = new BookBorrowable(book);
borrowable.BorrowOne();
Assert.AreEqual<int>(4, book.AvailableAmount);
}
}
}