ItemSpentTests.cs
6.83 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using System;
using NUnit.Framework;
namespace UnityEngine.Analytics.Tests
{
public partial class AnalyticsEventTests
{
[Test]
public void ItemSpent_CurrencyTypeTest(
[Values(AcquisitionType.Premium, AcquisitionType.Soft)] AcquisitionType currencyType)
{
var context = "test";
var amount = 1f;
var itemId = "test_item";
var balance = 1f;
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId));
EvaluateAnalyticsResult(m_Result);
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance));
EvaluateAnalyticsResult(m_Result);
}
[Test]
public void ItemSpent_ContextTest(
[Values("test", "", null)] string context)
{
var currencyType = AcquisitionType.Soft;
var amount = 1f;
var itemId = "test_item";
var balance = 1f;
if (string.IsNullOrEmpty(context))
{
Assert.Throws<ArgumentException>(() => AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId));
Assert.Throws<ArgumentException>(() => AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance));
}
else
{
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance));
EvaluateAnalyticsResult(m_Result);
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance));
EvaluateAnalyticsResult(m_Result);
}
}
[Test]
public void ItemSpent_AmountTest(
[Values(-1f, 0f, 1f)] float amount)
{
var currencyType = AcquisitionType.Soft;
var context = "test";
var itemId = "test_item";
var balance = 1f;
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId));
EvaluateAnalyticsResult(m_Result);
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance));
EvaluateAnalyticsResult(m_Result);
}
[Test]
public void ItemSpent_ItemIdTest(
[Values("test_item", "", null)] string itemId)
{
var currencyType = AcquisitionType.Soft;
var context = "test";
var amount = 1f;
var balance = 1f;
if (string.IsNullOrEmpty(itemId))
{
Assert.Throws<ArgumentException>(() => AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId));
Assert.Throws<ArgumentException>(() => AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance));
}
else
{
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId));
EvaluateAnalyticsResult(m_Result);
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance));
EvaluateAnalyticsResult(m_Result);
}
}
[Test]
public void ItemSpent_BalanceTest(
[Values(-1f, 0, 1f)] float balance)
{
var currencyType = AcquisitionType.Soft;
var context = "test";
var amount = 1f;
var itemId = "test_item";
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance));
EvaluateAnalyticsResult(m_Result);
}
[Test]
public void ItemSpent_ItemTypeTest(
[Values("test_type", "", null)] string itemType)
{
var currencyType = AcquisitionType.Soft;
var context = "test";
var amount = 1f;
var itemId = "test_item";
var balance = 1f;
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, itemType));
EvaluateAnalyticsResult(m_Result);
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance, itemType));
EvaluateAnalyticsResult(m_Result);
}
[Test]
public void ItemSpent_LevelTest(
[Values("test_level", "", null)] string level)
{
var currencyType = AcquisitionType.Soft;
var context = "test";
var amount = 1f;
var itemId = "test_item";
var balance = 1f;
var itemType = "test_type";
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, itemType, level));
EvaluateAnalyticsResult(m_Result);
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance, itemType, level));
EvaluateAnalyticsResult(m_Result);
}
[Test]
public void ItemSpent_TransactionIdTest(
[Values("test_id", "", null)] string transactionId)
{
var currencyType = AcquisitionType.Soft;
var context = "test";
var amount = 1f;
var itemId = "test_item";
var balance = 1f;
var itemType = "test_type";
var level = "test_level";
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, itemType, level, transactionId));
EvaluateAnalyticsResult(m_Result);
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance, itemType, level, transactionId));
EvaluateAnalyticsResult(m_Result);
}
[Test]
public void ItemSpent_CustomDataTest()
{
var currencyType = AcquisitionType.Soft;
var context = "test";
var amount = 1f;
var itemId = "test_item";
var balance = 1f;
var itemType = "test_type";
var level = "test_level";
var transactionId = "test_id";
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, itemType, level, transactionId, m_CustomData));
EvaluateCustomData(m_CustomData);
EvaluateAnalyticsResult(m_Result);
Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ItemSpent(currencyType, context, amount, itemId, balance, itemType, level, transactionId, m_CustomData));
EvaluateCustomData(m_CustomData);
EvaluateAnalyticsResult(m_Result);
}
}
}