Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Aug 1, 2023
1 parent 1bfd41c commit a5d3aa4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions starsky/starskytest/Helpers/FileIndexCompareHelperTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using starsky.foundation.database.Helpers;
using starsky.foundation.database.Models;
Expand Down Expand Up @@ -349,6 +350,12 @@ public void CompareNullableBool_NotFound()
Assert.IsNotNull(list);
}

public static void SetNull(object obj, string propertyName)
{
PropertyInfo propertyInfo = obj.GetType().GetProperty(propertyName);
propertyInfo.SetValue(obj, null);
}

[TestMethod]
public void CompareString_NotFound()
{
Expand All @@ -366,7 +373,8 @@ public void TestCompare_NullColor()
// Arrange
var sourceIndexItem = new FileIndexItem();
var updateObject = new FileIndexItem();
sourceIndexItem.ColorClass = ColorClassParser.Color.None;

SetNull(sourceIndexItem, "ColorClass");

// Act
var result = FileIndexCompareHelper.Compare(sourceIndexItem, updateObject);
Expand All @@ -381,13 +389,13 @@ public void TestCompare_NullDateTime()
// Arrange
var sourceIndexItem = new FileIndexItem();
var updateObject = new FileIndexItem();
sourceIndexItem.DateTime = DateTime.MinValue;
SetNull(sourceIndexItem, "DateTime");

// Act
var result = FileIndexCompareHelper.Compare(sourceIndexItem, updateObject);

// Assert
CollectionAssert.DoesNotContain(result, "DateTaken");
CollectionAssert.DoesNotContain(result, "DateTime");
}

[TestMethod]
Expand Down Expand Up @@ -441,7 +449,7 @@ public void TestCompare_NullUshort()
// Arrange
var sourceIndexItem = new FileIndexItem();
var updateObject = new FileIndexItem();
sourceIndexItem.IsoSpeed = 0;
SetNull(sourceIndexItem, "IsoSpeed");

// Act
var result = FileIndexCompareHelper.Compare(sourceIndexItem, updateObject);
Expand Down

0 comments on commit a5d3aa4

Please sign in to comment.