Skip to content

Commit

Permalink
Adjust unit test project name and add ScriptDictionary tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslcarter committed Mar 10, 2024
1 parent 9e823f5 commit 3280ef2
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Mockaco.AspNetCore/InternalsVisibleTo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Mockaco.Tests")]
[assembly: InternalsVisibleTo("Mockaco.AspNetCore.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
73 changes: 73 additions & 0 deletions test/Mockaco.AspNetCore.Tests/Common/StringDictionaryTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Xunit;
using Mockaco;
using FluentAssertions;

public class StringDictionaryTests
{
[Fact]
public void Add_WhenKeyNotExists_AddsKeyValue()
{
var dictionary = new StringDictionary();
var key = "testKey";
var value = "testValue";
dictionary.Add(key, value);
dictionary.ContainsKey(key).Should().BeTrue();
dictionary[key].Should().Be(value);
}

[Fact]
public void Add_WhenKeyExists_ReplacesValue()
{
var dictionary = new StringDictionary();
var key = "testKey";
var initialValue = "initialValue";
var newValue = "newValue";
dictionary.Add(key, initialValue);
dictionary.Add(key, newValue);
dictionary.ContainsKey(key).Should().BeTrue();
dictionary[key].Should().Be(newValue);
}

[Fact]
public void Replace_WhenKeyNotExists_AddsKeyValue()
{
var dictionary = new StringDictionary();
var key = "testKey";
var value = "testValue";
dictionary.Replace(key, value);
dictionary.ContainsKey(key).Should().BeTrue();
dictionary[key].Should().Be(value);
}

[Fact]
public void Replace_WhenKeyExists_ReplacesValue()
{
var dictionary = new StringDictionary();
var key = "testKey";
var initialValue = "initialValue";
var newValue = "newValue";
dictionary.Add(key, initialValue);
dictionary.Replace(key, newValue);
dictionary.ContainsKey(key).Should().BeTrue();
dictionary[key].Should().Be(newValue);
}

[Fact]
public void Indexer_Get_WhenKeyNotExists_ReturnsEmptyString()
{
var dictionary = new StringDictionary();
var key = "testKey";
var value = dictionary[key];
value.Should().BeEmpty();
}

[Fact]
public void Indexer_Set_UpdatesValue()
{
var dictionary = new StringDictionary();
var key = "testKey";
var value = "testValue";
dictionary[key] = value;
dictionary[key].Should().Be(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Mockaco.Tests</RootNamespace>
<RootNamespace>Mockaco.AspNetCore.Tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 3280ef2

Please sign in to comment.