Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions Utilities.Tests/Extensions/DictionaryExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
using System;
using System;
using System.Collections.Generic;
using FluentAssertions;
using NUnit.Framework;
using Utilities.Extensions;

namespace Utilities.Tests.Extensions
namespace Utilities.Tests.Extensions;

public class DictionaryExtensionsTests
{
public class DictionaryExtensionsTests
[Test]
public void AddMany_ShouldThrowArgumentException_WhenKeyAlreadyExists()
{
[Test]
public void AddMany_ShouldThrowArgumentException_WhenKeyAlreadyExists()
{
var dictionary = new Dictionary<string, int> { ["one"] = 1 };
var enumerable = new[] { ("one", 1), ("two", 2) };
var dictionary = new Dictionary<string, int> { ["one"] = 1 };
var enumerable = new[] { ("one", 1), ("two", 2) };

var action = () => dictionary.AddMany(enumerable);
var action = () => dictionary.AddMany(enumerable);

action.Should().Throw<ArgumentException>();
}
action.Should().Throw<ArgumentException>();
}

[Test]
public void AddMany_ShouldAddAllKeyValuePairs()
{
var dictionary = new Dictionary<string, int> { ["one"] = 1 };
var enumerable = new[] { ("two", 2), ("three", 3) };
[Test]
public void AddMany_ShouldAddAllKeyValuePairs()
{
var dictionary = new Dictionary<string, int> { ["one"] = 1 };
var enumerable = new[] { ("two", 2), ("three", 3) };

dictionary.AddMany(enumerable);
dictionary.AddMany(enumerable);

dictionary.Should().HaveCount(3);
dictionary.Should().HaveCount(3);

dictionary.Should().ContainKey("one").WhichValue.Should().Be(1);
dictionary.Should().ContainKey("two").WhichValue.Should().Be(2);
dictionary.Should().ContainKey("three").WhichValue.Should().Be(3);
}
dictionary.Should().ContainKey("one").WhichValue.Should().Be(1);
dictionary.Should().ContainKey("two").WhichValue.Should().Be(2);
dictionary.Should().ContainKey("three").WhichValue.Should().Be(3);
}
}
Loading