C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
Test_Simulation.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3
4using AnalyzeRe;
9
10#if MSTEST
11using Microsoft.VisualStudio.TestTools.UnitTesting;
12#elif NUNIT
13using TestClass = NUnit.Framework.TestFixtureAttribute;
14using TestMethod = NUnit.Framework.TestAttribute;
15using TestCategory = NUnit.Framework.CategoryAttribute;
16#endif
17
19{
21 [TestClass]
26
28 [TestClass]
30 {
31 #region Set Up and Configuration
32 private const string TypeName = "StaticSimulation";
35
36 protected override string POSTData => Samples.CSV.Static_Simulation_Data;
37 #endregion Set Up and Configuration
38
39 [TestMethod, TestCategory(TypeName), TestCategory("Skipped")]
40 public override void Test_Resource_Search()
41 {
42 Skip.Indefinitely("Bug ARE-5472 - Simulations don't support search by description.");
43 base.Test_Resource_Search();
44 }
45
46 #region POST
47 #region trial_count
48 [TestMethod, TestCategory(TypeName)]
50 {
52 invalidTrialCount.trial_count = 9;
53 GenericTest.POST_InvalidResourceWithData_Fails(invalidTrialCount,
55 }
56 #endregion trial_count
57
58 #region notes
59 [TestMethod, TestCategory(TypeName)]
60 [Obsolete("This tests a now obsolete property for backwards compatibility purposes.")]
62 {
63 POST_Attribute_Null(s => s.notes);
64 }
65 [TestMethod, TestCategory(TypeName)]
66 [Obsolete("This tests a now obsolete property for backwards compatibility purposes.")]
68 {
69 POST_WithValue(s => s.notes, new Dictionary<string, object>(), true);
70 }
71 [TestMethod, TestCategory(TypeName)]
72 [Obsolete("This tests a now obsolete property for backwards compatibility purposes.")]
74 {
75 POST_WithValue(s => s.notes, new Dictionary<string, object> { { "Test$.", "Test" } }, true);
76 }
77 #endregion notes
78 #endregion POST
79
80 #region PUT
81 #region trial_count
82 [TestMethod, TestCategory(TypeName)]
84 {
85 PUT_WithValue(s => s.trial_count, 1234, true);
86 }
87 #endregion trial_count
88
89 #region notes
90 [TestMethod, TestCategory(TypeName)]
91 [Obsolete("This tests a now obsolete property for backwards compatibility purposes.")]
93 {
94 PUT_WithValue(s => s.notes, new Dictionary<string, object> { { "Modified 1", "String" }, { "Modified 2", 10001 } }, true);
95 }
96 [TestMethod, TestCategory(TypeName)]
97 [Obsolete("This tests a now obsolete property for backwards compatibility purposes.")]
99 {
100 PUT_WithValue(s => s.notes, new Dictionary<string, object> { { "Test$.", "Test" } }, true);
101 }
102 [TestMethod, TestCategory(TypeName)]
103 [Obsolete("This tests a now obsolete property for backwards compatibility purposes.")]
105 {
106 PUT_Attribute_Null(s => s.notes);
107 }
108 [TestMethod, TestCategory(TypeName)]
109 [Obsolete("This tests a now obsolete property for backwards compatibility purposes.")]
111 {
112 PUT_WithValue(s => s.notes, new Dictionary<string, object>(), true);
113 }
114 #endregion notes
115 #endregion PUT
116
117 #region Test Data
118 [TestMethod, TestCategory(TypeName)]
120 {
121 GenericTest.POST_ValidResourceWithData(TestResource,
122 "\"TrialId\",\"Day\",\"EventId\"");
123 }
124 #endregion Test Data
125 }
126
127 #region Abstract Base Simulation Tests
133 [TestClass]
136 {
137 private const string TypeName = "Simulation";
138
139 #region POST
140 #region name
141 [TestMethod, TestCategory(TypeName)]
142 public virtual void Test_Simulation_POST_Name_Null()
143 {
144 POST_Attribute_Null(s => s.name);
145 }
146 [TestMethod, TestCategory(TypeName)]
148 {
149 POST_StringAttribute_Empty(s => s.name);
150 }
151 #endregion name
152 #region start_date
153 [TestMethod, TestCategory(TypeName)]
155 {
157 POST_WithValue(l => l.start_date, minUtcDateTime, true);
158 }
159
160 [TestMethod, TestCategory(TypeName)]
162 {
163 DateTime maxUtcDateTime = new DateTime(DateTime.MaxValue.Ticks, DateTimeKind.Utc);
164 POST_WithValue(l => l.start_date, maxUtcDateTime, true);
165 }
166 #endregion start_date
167
168 #region event_catalogs
169 [TestMethod, TestCategory(TypeName)]
171 {
172 POST_Attribute_Null(s => s.event_catalogs);
173 }
174 [TestMethod, TestCategory(TypeName)]
176 {
177 POST_ListAttribute_Empty(s => s.event_catalogs);
178 }
179 [TestMethod, TestCategory(TypeName)]
181 {
182 POST_ReferenceList_NonExistantId(a => a.event_catalogs);
183 }
184 #endregion event_catalogs
185 #endregion POST
186
187 #region PUT
188 #region name
189 [TestMethod, TestCategory(TypeName)]
190 public virtual void Test_Simulation_PUT_Name()
191 {
192 PUT_WithValue(s => s.name, "Modified Name", true);
193 }
194 [TestMethod, TestCategory(TypeName)]
195 public virtual void Test_Simulation_PUT_Name_Null()
196 {
197 PUT_Attribute_Null(s => s.name);
198 }
199 [TestMethod, TestCategory(TypeName)]
200 public virtual void Test_Simulation_PUT_Name_Blank()
201 {
202 PUT_StringAttribute_Empty(s => s.name);
203 }
204 #endregion name
205
206 #region start_date
207 [TestMethod, TestCategory(TypeName)]
209 {
211 PUT_WithValue(l => l.start_date, minUtcDateTime, true);
212 }
213
214 [TestMethod, TestCategory(TypeName)]
216 {
217 DateTime maxUtcDateTime = new DateTime(DateTime.MaxValue.Ticks, DateTimeKind.Utc);
218 PUT_WithValue(l => l.start_date, maxUtcDateTime, true);
219 }
220 #endregion start_date
221
222 #region event_catalogs
223 [TestMethod, TestCategory(TypeName)]
225 {
226 PUT_WithValue(s => s.event_catalogs,
227 new List<IReference<EventCatalog>> { Samples.EventCatalog.AsReference }, true);
228 }
229
230 [TestMethod, TestCategory(TypeName)]
232 {
233 PUT_Attribute_Null(s => s.event_catalogs);
234 }
235 [TestMethod, TestCategory(TypeName)]
237 {
238 PUT_ListAttribute_Empty(s => s.event_catalogs);
239 }
240 [TestMethod, TestCategory(TypeName)]
242 {
243 PUT_ReferenceList_NonExistantId(a => a.event_catalogs);
244 }
245 #endregion event_catalogs
246 #endregion PUT
247 }
248 #endregion Abstract Base Simulation Tests
249}
Tests for a stored resource collection which do not require an instance of that resource to be define...
Exposes the various sample CSV files as strings.
Definition Samples.CSV.cs:9
static string Static_Simulation_Data
Exposes sample resource objects, with built-in methods for injecting dependencies.
Definition Samples.cs:14
IInjectableResource< StaticSimulation > Simulation_StaticSimulation
Tests that do not require a Simulation instance.
override IResourceCollection< Simulation > collection_source
StaticSimulation tests that do not rely on the /data endpoint.
override IInjectableResource< StaticSimulation > TestInjectableResource
Test for Simulations that have a data endpoint.
Generic Unit test implementations that will test REST methods on arbitrary resources.
Class used in unit tests to mark tests as skipped by using Assert.Inconclusive() method.
Definition SkipUntil.cs:14
static void Indefinitely(string ticket=null)
Skip the specified test.
Definition SkipUntil.cs:54
Describes a collection of resources which can be listed.
API methods / requests made available to the user.
static readonly ResourceCollection< Simulation > Simulations
The collection of Simulations on the server.
Exception raised when the commit process fails.
Representation of a simulation of a set of trials each representing an event occurrence sequence.
Definition Simulation.cs:14
A pre-simulated representation of a Simulation (SimGrid).
Describes an APIResource class that adds a "/data" sub-resource, since this functionality is common t...