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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Algorithms.DataCompression;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace Algorithms.Tests.Compressors;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms.Tests/Compressors/HuffmanCompressorTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using Algorithms.DataCompression;
using Algorithms.Sorters.Comparison;
using FluentAssertions;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace Algorithms.Tests.Compressors;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Compressors/ShannonFanoCompressorTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Algorithms.DataCompression;
using Algorithms.Knapsack;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace Algorithms.Tests.Compressors;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Compressors/TranslatorTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using Algorithms.DataCompression;
using NUnit.Framework;

namespace Algorithms.Tests.Compressors;

Expand Down
4 changes: 0 additions & 4 deletions Algorithms.Tests/Crypto/Digests/AsconDigestTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Text;
using Algorithms.Crypto.Digests;
using Algorithms.Crypto.Exceptions;
using FluentAssertions;
using NUnit.Framework;

namespace Algorithms.Tests.Crypto.Digests;

Expand Down
6 changes: 1 addition & 5 deletions Algorithms.Tests/Crypto/Digests/Md2DigestTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Text;
using Algorithms.Crypto.Digests;
using FluentAssertions;
using NUnit.Framework;
using Algorithms.Crypto.Digests;

namespace Algorithms.Tests.Crypto.Digesters;

Expand Down
4 changes: 0 additions & 4 deletions Algorithms.Tests/Crypto/Exceptions/CryptoExceptionTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Algorithms.Crypto.Exceptions;
using NUnit.Framework;
using FluentAssertions;
using System;


namespace Algorithms.Tests.Crypto.Exceptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using NUnit.Framework;
using FluentAssertions;
using System;
using Algorithms.Crypto.Exceptions;

namespace Algorithms.Tests.Crypto.Exceptions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using NUnit.Framework;
using FluentAssertions;
using System;
using Algorithms.Crypto.Exceptions;

namespace Algorithms.Tests.Crypto.Exceptions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Algorithms.Crypto.Paddings;
using FluentAssertions;
using NUnit.Framework;
using Algorithms.Crypto.Paddings;

namespace Algorithms.Tests.Crypto.Paddings;

Expand Down
6 changes: 1 addition & 5 deletions Algorithms.Tests/Crypto/Paddings/Iso7816D4PaddingTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Linq;
using Algorithms.Crypto.Paddings;
using FluentAssertions;
using NUnit.Framework;
using Algorithms.Crypto.Paddings;

namespace Algorithms.Tests.Crypto.Paddings;

Expand Down
5 changes: 1 addition & 4 deletions Algorithms.Tests/Crypto/Paddings/Pkcs7PaddingTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Algorithms.Crypto.Paddings;
using FluentAssertions;
using NUnit.Framework;
using Algorithms.Crypto.Paddings;

namespace Algorithms.Tests.Crypto.Paddings;

Expand Down
7 changes: 2 additions & 5 deletions Algorithms.Tests/Crypto/Paddings/TbcPaddingTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Algorithms.Crypto.Paddings;
using FluentAssertions;
using NUnit.Framework;
using Algorithms.Crypto.Paddings;

namespace Algorithms.Tests.Crypto.Paddings;

Expand All @@ -18,7 +15,7 @@ public void AddPadding_WhenInputOffsetIsZero_ShouldPadWithLastBit()
var result = padding.AddPadding(input, inputOffset);

result.Should().Be(4);
input.Should().BeEquivalentTo(new byte[]{0xff, 0xff, 0xff, 0xff});
input.Should().BeEquivalentTo(new byte[] { 0xff, 0xff, 0xff, 0xff });
}

[Test]
Expand Down
5 changes: 1 addition & 4 deletions Algorithms.Tests/Crypto/Paddings/X932PaddingTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Algorithms.Crypto.Paddings;
using FluentAssertions;
using NUnit.Framework;
using Algorithms.Crypto.Paddings;

namespace Algorithms.Tests.Crypto.Paddings;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms.Tests/Crypto/Utils/ByteEncodingUtils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using NUnit.Framework;
using FluentAssertions;
using System;
using Algorithms.Crypto.Utils;

namespace Algorithms.Tests.Crypto.Utils
Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Crypto/Utils/LongUtilsTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using NUnit.Framework;
using FluentAssertions;
using Algorithms.Crypto.Utils;

namespace Algorithms.Tests.Crypto.Utils
Expand Down
3 changes: 0 additions & 3 deletions Algorithms.Tests/Crypto/Utils/ValidationUtilsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using NUnit.Framework;
using FluentAssertions;
using System;
using Algorithms.Crypto.Utils;
using Algorithms.Crypto.Exceptions;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms.Tests/Encoders/AutokeyEncoderTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Algorithms.Encoders;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace Algorithms.Tests.Encoders
{
Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Encoders/BlowfishEncoderTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Algorithms.Encoders;
using FluentAssertions;
using NUnit.Framework;

namespace Algorithms.Tests.Encoders;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Encoders/CaesarEncoderTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Algorithms.Encoders;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace Algorithms.Tests.Encoders;

Expand Down
11 changes: 4 additions & 7 deletions Algorithms.Tests/Encoders/FeistelCipherTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Algorithms.Encoders;
using NUnit.Framework;
using NUnit.Framework.Internal;
using System;

namespace Algorithms.Tests.Encoders;

Expand All @@ -26,10 +23,10 @@ public static void DecodedStringIsTheSame([Random(100)] uint key)
Assert.That(decoded, Is.EqualTo(message));
}

[TestCase("00001111", (uint)0x12345678)]
[TestCase("00001111222233334444555566667", (uint)0x12345678)]
[TestCase("000011112222333344445555666677", (uint)0x12345678)]
[TestCase("0000111122223333444455556666777", (uint)0x12345678)]
[TestCase("00001111", (uint)0x12345678)]
[TestCase("00001111222233334444555566667", (uint)0x12345678)]
[TestCase("000011112222333344445555666677", (uint)0x12345678)]
[TestCase("0000111122223333444455556666777", (uint)0x12345678)]
// The plain text will be padded to fill the size of block (16 bytes), so the encoded message should be aligned with the rule
// (text.Length % 16 == 0)
public static void TestEncodedMessageSize(string testCase, uint key)
Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Encoders/HillEnconderTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Algorithms.Encoders;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace Algorithms.Tests.Encoders;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms.Tests/Encoders/NysiisEncoderTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Algorithms.Encoders;
using NUnit.Framework;

namespace Algorithms.Tests.Encoders;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms.Tests/Encoders/SoundexEncoderTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Algorithms.Encoders;
using NUnit.Framework;

namespace Algorithms.Tests.Encoders;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms.Tests/Encoders/VigenereEncoderTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Algorithms.Encoders;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace Algorithms.Tests.Encoders;

Expand Down
13 changes: 4 additions & 9 deletions Algorithms.Tests/Financial/PresentValueTests.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Algorithms.Financial;
using FluentAssertions;
using NUnit.Framework;

namespace Algorithms.Tests.Financial;

public static class PresentValueTests
{
[TestCase(0.13,new[] { 10.0, 20.70, -293.0, 297.0 },4.69)]
[TestCase(0.07,new[] { -109129.39, 30923.23, 15098.93, 29734.0, 39.0 }, -42739.63)]
[TestCase(0.13, new[] { 10.0, 20.70, -293.0, 297.0 }, 4.69)]
[TestCase(0.07, new[] { -109129.39, 30923.23, 15098.93, 29734.0, 39.0 }, -42739.63)]
[TestCase(0.07, new[] { 109129.39, 30923.23, 15098.93, 29734.0, 39.0 }, 175519.15)]
[TestCase(0.0, new[] { 109129.39, 30923.23, 15098.93, 29734.0, 39.0 }, 184924.55)]

public static void Present_Value_General_Tests(double discountRate,double[] cashFlow ,double expected)
public static void Present_Value_General_Tests(double discountRate, double[] cashFlow, double expected)
=>
PresentValue.Calculate(discountRate, cashFlow.ToList())
.Should()
.Be(expected);


[TestCase(-1.0, new[] { 10.0, 20.70, -293.0, 297.0 })]
[TestCase(1.0,new double[] {})]
[TestCase(1.0, new double[] { })]

public static void Present_Value_Exception_Tests(double discountRate, double[] cashFlow)
=> Assert.Throws<ArgumentException>(() => PresentValue.Calculate(discountRate, cashFlow.ToList()));
Expand Down
21 changes: 21 additions & 0 deletions Algorithms.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// -----------------------------------------------------------------------------
// Global using directives for the C-Sharp solution.
// These namespaces are imported globally so they don’t need to be repeatedly declared
// in individual files, improving readability and reducing boilerplate.
//
// Guidelines:
// - Keep only the most commonly used namespaces here.
// - Add project-specific namespaces (e.g., Utilities.Extensions) only if they are
// required across the majority of files in the project.
// - Avoid placing rarely used namespaces here to maintain clarity.
// -----------------------------------------------------------------------------

global using System; // Core base classes and fundamental types
global using System.Collections.Generic; // Generic collection types (List, Dictionary, etc.)
global using System.Linq; // LINQ query operators for collections
global using System.Numerics; // Numeric types such as BigInteger and Complex
global using System.Text; // Text encoding, StringBuilder, etc.
global using Utilities.Extensions; // Common extension methods used across the solution
global using NUnit.Framework; // Testing framework providing attributes and assertions for test cases
global using NUnit.Framework.Internal; // Internal NUnit infrastructure (test context, utilities) — generally used for advanced or framework-level test control
global using FluentAssertions; // Assertion library for more readable and expressive unit tests
4 changes: 0 additions & 4 deletions Algorithms.Tests/Graph/BellmanFordTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Algorithms.Graph;
using DataStructures.Graph;
using NUnit.Framework;
using FluentAssertions;
using System.Collections.Generic;
using System;

namespace Algorithms.Tests.Graph;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Graph/BreadthFirstSearchTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Algorithms.Graph;
using DataStructures.Graph;
using NUnit.Framework;
using System.Collections.Generic;

namespace Algorithms.Tests.Graph;

Expand Down
1 change: 0 additions & 1 deletion Algorithms.Tests/Graph/BreadthFirstTreeTraversalTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Algorithms.Graph;
using DataStructures.BinarySearchTree;
using NUnit.Framework;

namespace Algorithms.Tests.Graph;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Graph/DepthFirstSearchTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Algorithms.Graph;
using DataStructures.Graph;
using NUnit.Framework;
using System.Collections.Generic;

namespace Algorithms.Tests.Graph;

Expand Down
3 changes: 0 additions & 3 deletions Algorithms.Tests/Graph/Dijkstra/DijkstraTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using Algorithms.Graph.Dijkstra;
using DataStructures.Graph;
using FluentAssertions;
using NUnit.Framework;

namespace Algorithms.Tests.Graph.Dijkstra;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Graph/FloydWarshallTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Algorithms.Graph;
using DataStructures.Graph;
using NUnit.Framework;
using FluentAssertions;

namespace Algorithms.Tests.Graph;

Expand Down
6 changes: 1 addition & 5 deletions Algorithms.Tests/Graph/KosarajuTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Algorithms.Graph;
using DataStructures.Graph;
using NUnit.Framework;
using FluentAssertions;
using System.Collections.Generic;
using System.Linq;

namespace Algorithms.Tests.Graph;

Expand Down Expand Up @@ -34,7 +30,7 @@ public void GetRepresentativesTest()
graph.AddEdge(vertex5, vertex6, 1);

// Run the agorithm and obtain the representative vertex of the SCC to which each vertex belongs.
Dictionary<Vertex<int>,Vertex<int>> result = Kosaraju<int>.GetRepresentatives(graph);
Dictionary<Vertex<int>, Vertex<int>> result = Kosaraju<int>.GetRepresentatives(graph);

// Check every Vertex belongs to a SCC
result.Should().ContainKey(vertex1);
Expand Down
5 changes: 0 additions & 5 deletions Algorithms.Tests/Graph/MinimumSpanningTree/KruskalTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Algorithms.Graph.MinimumSpanningTree;
using FluentAssertions;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Algorithms.Tests.Graph.MinimumSpanningTree;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Algorithms.Graph.MinimumSpanningTree;
using FluentAssertions;
using NUnit.Framework;
using System;
using System.Linq;

namespace Algorithms.Tests.Graph.MinimumSpanningTree;

Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Helpers/IntComparer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;

namespace Algorithms.Tests.Helpers;

internal class IntComparer : IComparer<int>
Expand Down
2 changes: 0 additions & 2 deletions Algorithms.Tests/Helpers/RandomHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using NUnit.Framework;

namespace Algorithms.Tests.Helpers;

internal static class RandomHelper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Algorithms.Knapsack;
using NUnit.Framework;
using FluentAssertions;

namespace Algorithms.Tests.Knapsack;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Linq;
using Algorithms.Knapsack;
using NUnit.Framework;

namespace Algorithms.Tests.Knapsack;

Expand Down
Loading