You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/Trash.Tests/Extensions/DictionaryExtensionsTest.cs

43 lines
1.1 KiB

using System.Collections.Generic;
using FluentAssertions;
using NUnit.Framework;
using Trash.Extensions;
namespace Trash.Tests.Extensions
{
[TestFixture]
public class DictionaryExtensionsTest
{
private class MySampleValue
{
}
[Test]
public void GetOrCreate_ItemExists_ReturnExistingItem()
{
var sample = new MySampleValue();
var dict = new Dictionary<int, MySampleValue> {{100, sample}};
var theValue = dict.GetOrCreate(100);
dict.Should().HaveCount(1);
dict.Should().Contain(100, sample);
dict.Should().ContainValue(theValue);
theValue.Should().Be(sample);
}
[Test]
public void GetOrCreate_NoItemExists_ItIsCreated()
{
var dict = new Dictionary<int, MySampleValue>();
var theValue = dict.GetOrCreate(100);
dict.Should().HaveCount(1);
dict.Should().Contain(100, theValue);
}
[Test]
public void GetOrDefault_ItemExists_ReturnExistingItem()
{
}
}
}