Files
speckle-sharp-connectors/Sdk/Speckle.Connectors.Common.Tests/Operations/ProgressDisplayManagerTests.cs
T
Adam Hathcock 2f8f0d0f6f test: add tests for receive operation (#661)
* add tests for receive operation

* clean up some items and tests

* First initialization changes for SDK 3.2

* Update to SDK 3.2

* merge fixes

* fmt

* ifc changes

* fix tests and remove fakes again

* fmt

* remove extra tests from local sln

* update locks for 3.2

* fix mismerge

---------

Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com>
2025-04-16 16:58:22 +01:00

37 lines
1.3 KiB
C#

using FluentAssertions;
using NUnit.Framework;
using Speckle.Connectors.Common.Operations;
using Speckle.Sdk.Transports;
using Speckle.Testing;
namespace Speckle.Connectors.Common.Tests.Operations;
public class ProgressDisplayManagerTests : MoqTest
{
[Test]
[TestCase(5, 10, 0.5)]
[TestCase(1, null, null)]
[TestCase(10, 10, 1)]
public void TestPercentage(long count, long? total, double? percentage)
{
var stopwatch = Create<IStopwatchManager>();
var manager = new ProgressDisplayManager(stopwatch.Object);
var p = manager.CalculatePercentage(new ProgressArgs(ProgressEvent.DownloadBytes, count, total));
p.Should().Be(percentage);
}
[Test]
[SetCulture("en-GB")]
[TestCase(1, 1, 6, 10, "5.00 bytes / sec")]
[TestCase(1, 0, 6, 10, "0 bytes / sec")] //infinity
[TestCase(1 * 1024 * 1024, 1, 6 * 1024 * 1024, 10 * 1024 * 1024, "5.00 MB / sec")]
public void TestSpeed(long previousCount, long elapsed, long count, long? total, string? percentage)
{
var stopwatch = Create<IStopwatchManager>();
stopwatch.Setup(x => x.ElapsedSeconds).Returns(elapsed);
var manager = new ProgressDisplayManager(stopwatch.Object) { LastCount = previousCount };
var p = manager.CalculateSpeed(new ProgressArgs(ProgressEvent.DownloadBytes, count, total));
p.Should().Be(percentage);
}
}