|
8 | 8 | using OnTopic.Attributes;
|
9 | 9 | using OnTopic.Collections;
|
10 | 10 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
| 11 | +using System.Globalization; |
11 | 12 |
|
12 | 13 | namespace OnTopic.Tests {
|
13 | 14 |
|
@@ -251,6 +252,65 @@ public void SetValue_ValueUnchanged_IsNotDirty() {
|
251 | 252 |
|
252 | 253 | }
|
253 | 254 |
|
| 255 | + /*========================================================================================================================== |
| 256 | + | TEST: IS DIRTY: DIRTY VALUES: RETURNS TRUE |
| 257 | + \-------------------------------------------------------------------------------------------------------------------------*/ |
| 258 | + /// <summary> |
| 259 | + /// Populates the <see cref="AttributeValueCollection"/> with a <see cref="AttributeValue"/> that is marked as <see |
| 260 | + /// cref="AttributeValue.IsDirty"/>. Confirms that <see cref="AttributeValueCollection.IsDirty(Boolean)"/> returns |
| 261 | + /// <c>true</c>/ |
| 262 | + /// </summary> |
| 263 | + [TestMethod] |
| 264 | + public void IsDirty_DirtyValues_ReturnsTrue() { |
| 265 | + |
| 266 | + var topic = TopicFactory.Create("Test", "Container"); |
| 267 | + |
| 268 | + topic.Attributes.SetValue("Foo", "Bar"); |
| 269 | + |
| 270 | + Assert.IsTrue(topic.Attributes.IsDirty()); |
| 271 | + |
| 272 | + } |
| 273 | + |
| 274 | + /*========================================================================================================================== |
| 275 | + | TEST: IS DIRTY: NO DIRTY VALUES: RETURNS FALSE |
| 276 | + \-------------------------------------------------------------------------------------------------------------------------*/ |
| 277 | + /// <summary> |
| 278 | + /// Populates the <see cref="AttributeValueCollection"/> with a <see cref="AttributeValue"/> that is <i>not</i> marked as |
| 279 | + /// <see cref="AttributeValue.IsDirty"/>. Confirms that <see cref="AttributeValueCollection.IsDirty(Boolean)"/> returns |
| 280 | + /// <c>false</c>/ |
| 281 | + /// </summary> |
| 282 | + [TestMethod] |
| 283 | + public void IsDirty_NoDirtyValues_ReturnsFalse() { |
| 284 | + |
| 285 | + var topic = TopicFactory.Create("Test", "Container", 1); |
| 286 | + |
| 287 | + topic.Attributes.SetValue("Foo", "Bar", false); |
| 288 | + |
| 289 | + Assert.IsFalse(topic.Attributes.IsDirty()); |
| 290 | + |
| 291 | + } |
| 292 | + |
| 293 | + /*========================================================================================================================== |
| 294 | + | TEST: IS DIRTY: EXCLUDE LAST MODIFIED: RETURNS FALSE |
| 295 | + \-------------------------------------------------------------------------------------------------------------------------*/ |
| 296 | + /// <summary> |
| 297 | + /// Populates the <see cref="AttributeValueCollection"/> with a <see cref="AttributeValue"/> that is <i>not</i> marked as |
| 298 | + /// <see cref="AttributeValue.IsDirty"/> as well as a <c>LastModified</c> <see cref="AttributeValue"/> that is. Confirms |
| 299 | + /// that <see cref="AttributeValueCollection.IsDirty(Boolean)"/> returns <c>false</c>. |
| 300 | + /// </summary> |
| 301 | + [TestMethod] |
| 302 | + public void IsDirty_ExcludeLastModified_ReturnsFalse() { |
| 303 | + |
| 304 | + var topic = TopicFactory.Create("Test", "Container", 1); |
| 305 | + |
| 306 | + topic.Attributes.SetValue("Foo", "Bar", false); |
| 307 | + topic.Attributes.SetValue("LastModified", DateTime.Now.ToString(CultureInfo.InvariantCulture)); |
| 308 | + topic.Attributes.SetValue("LastModifiedBy", "System"); |
| 309 | + |
| 310 | + Assert.IsFalse(topic.Attributes.IsDirty(true)); |
| 311 | + |
| 312 | + } |
| 313 | + |
254 | 314 | /*==========================================================================================================================
|
255 | 315 | | TEST: SET VALUE: INVALID VALUE: THROWS EXCEPTION
|
256 | 316 | \-------------------------------------------------------------------------------------------------------------------------*/
|
|
0 commit comments