-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1351 Added tests for the Assessments.Transformation project
- Loading branch information
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Assessments.Transformation.Tests/Assessments.Transformation.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MSTest" Version="3.1.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Assessments.Transformation\Assessments.Transformation.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
62 changes: 62 additions & 0 deletions
62
Assessments.Transformation.Tests/DynamicPropertyObjectComparerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Assessments.Transformation.Models; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using static Assessments.Transformation.PublishDynamicProperties; | ||
|
||
namespace Assessments.Transformation.Tests | ||
{ | ||
[TestClass] | ||
public class DynamicPropertyObjectComparerTests | ||
{ | ||
[TestMethod] | ||
public void GetHashCode_SameObject_ReturnsSameHashCode() | ||
{ | ||
// Arrange | ||
var comparer = new DynamicPropertyObjectComparer(); | ||
var dynamicProperty = new DynamicProperty { Id = "1", References = new string[0], Properties = new DynamicProperty.Property[0] }; | ||
|
||
// Act | ||
int hashCode1 = comparer.GetHashCode(dynamicProperty); | ||
int hashCode2 = comparer.GetHashCode(dynamicProperty); | ||
|
||
// Assert | ||
Assert.AreEqual(hashCode1, hashCode2); | ||
} | ||
|
||
[TestMethod] | ||
public void GetHashCode_EqualObjects_ReturnsSameHashCode() | ||
{ | ||
// Arrange | ||
var comparer = new DynamicPropertyObjectComparer(); | ||
var dynamicProperty1 = new DynamicProperty { Id = "1", References = new string[1] { "Ref1" }, Properties = new DynamicProperty.Property[1] { new DynamicProperty.Property() { Name = "test1" } } }; | ||
var dynamicProperty2 = new DynamicProperty { Id = "1", References = new string[1] { "Ref1" }, Properties = new DynamicProperty.Property[1] { new DynamicProperty.Property() { Name = "test1" } } }; | ||
|
||
// Act | ||
int hashCode1 = comparer.GetHashCode(dynamicProperty1); | ||
int hashCode2 = comparer.GetHashCode(dynamicProperty2); | ||
|
||
// Assert | ||
Assert.AreEqual(hashCode1, hashCode2); | ||
} | ||
|
||
[TestMethod] | ||
public void GetHashCode_DifferentObjects_ReturnsDifferentHashCode() | ||
{ | ||
// Arrange | ||
var comparer = new DynamicPropertyObjectComparer(); | ||
var dynamicProperty1 = new DynamicProperty { Id = "1", References = new string[1] { "Ref1" }, Properties = new DynamicProperty.Property[1] { new DynamicProperty.Property() { Name = "test1" } } }; | ||
var dynamicProperty2 = new DynamicProperty { Id = "2", References = new string[1] { "Ref2" }, Properties = new DynamicProperty.Property[1] { new DynamicProperty.Property() { Name = "test2" } } }; | ||
|
||
// Act | ||
int hashCode1 = comparer.GetHashCode(dynamicProperty1); | ||
int hashCode2 = comparer.GetHashCode(dynamicProperty2); | ||
|
||
// Assert | ||
Assert.AreNotEqual(hashCode1, hashCode2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
Console.WriteLine("Hello, World!"); |