-
Notifications
You must be signed in to change notification settings - Fork 1
/
DiscountConditionTests.cs
42 lines (37 loc) · 1.28 KB
/
DiscountConditionTests.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
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTest;
[TestClass]
public class DiscountConditionTests
{
[TestMethod]
public void IsDiscountable_PERIOD()
{
// Arrange
DiscountCondition dc = new DiscountCondition()
{
Type = DiscountConditionType.PERIOD,
DayOfWeek = DayOfWeek.Saturday,
StartTime = new DateTime(2022, 3, 12, 12, 00, 00),
EndTime = new DateTime(2022, 3, 12, 22, 00, 00)
};
// Action and Assert
Assert.IsTrue(dc.IsDiscountable(DayOfWeek.Saturday, new DateTime(2022, 3, 12, 18, 00, 00)));
Assert.IsFalse(dc.IsDiscountable(DayOfWeek.Saturday, new DateTime(2022, 3, 12, 8, 00, 00)));
Assert.IsFalse(dc.IsDiscountable(DayOfWeek.Sunday, new DateTime(2022, 3, 12, 8, 00, 00)));
Assert.IsFalse(dc.IsDiscountable(DayOfWeek.Sunday, new DateTime(2022, 3, 12, 8, 00, 00)));
}
[TestMethod]
public void IsDiscountable_SEQUENCE()
{
// Arrange
DiscountCondition dc = new DiscountCondition()
{
Type = DiscountConditionType.SEQUENCE,
Sequence = 2
};
// Action and Assert
Assert.IsTrue(dc.IsDiscountable(2));
Assert.IsFalse(dc.IsDiscountable(1));
}
}