-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from bCamba/feature-fluent-memory-limit
Add fluent memory limit
- Loading branch information
Showing
5 changed files
with
131 additions
and
12 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
Ductus.FluentDocker.Tests/ExtensionTests/ConversionExtensionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System.Numerics; | ||
using Ductus.FluentDocker.Extensions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Ductus.FluentDocker.Tests.ExtensionTests | ||
{ | ||
[TestClass] | ||
public class ConversionExtensionTests | ||
{ | ||
[TestMethod] | ||
[DataRow("")] | ||
[DataRow(null)] | ||
public void NullStringShallGiveMinimumValue(string input) | ||
{ | ||
var num = input.Convert(); | ||
Assert.IsTrue(string.IsNullOrEmpty(input)); | ||
Assert.AreEqual(long.MinValue, num); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow("2googles")] | ||
[DataRow("42p")] | ||
[DataRow("wrongFormat42")] | ||
[DataRow("-3498lfk")] | ||
public void InvalidUnitInputShallGiveMinimumValue(string input) | ||
{ | ||
var num = input.Convert(); | ||
Assert.AreEqual(long.MinValue, num); | ||
} | ||
|
||
[TestMethod] | ||
public void LessThanLongMinimumValueShallGiveMinimumValue() | ||
{ | ||
var lessThanMinimum = (new BigInteger(long.MinValue)) - 1; | ||
var input = lessThanMinimum.ToString() + "g"; | ||
|
||
var num = input.Convert(); | ||
Assert.AreEqual(long.MinValue, num); | ||
} | ||
|
||
[TestMethod] | ||
public void GreaterThanLongMaximumValueShallGiveMinimumValue() | ||
{ | ||
var greaterThanMaximum = (new BigInteger(long.MaxValue)) + 1; | ||
var input = greaterThanMaximum.ToString() + "g"; | ||
|
||
var num = input.Convert(); | ||
Assert.AreEqual(long.MinValue, num); | ||
} | ||
|
||
[TestMethod] | ||
public void ValidByteInputShallGiveExactNumber() | ||
{ | ||
var input = "42b"; | ||
|
||
var num = input.Convert(); | ||
Assert.AreEqual(42, num); | ||
} | ||
|
||
[TestMethod] | ||
public void ValidKilobyteInputShallGiveCorrectKilobyteNumber() | ||
{ | ||
var input = "42k"; | ||
|
||
var num = input.Convert(); | ||
Assert.AreEqual(43008, num); | ||
} | ||
|
||
[TestMethod] | ||
public void ValidMegabyteInputShallGiveCorrectMegabyteNumber() | ||
{ | ||
var input = "42m"; | ||
|
||
var num = input.Convert(); | ||
Assert.AreEqual(44040192, num); | ||
} | ||
|
||
[TestMethod] | ||
public void ValidGigabyteInputShallGiveCorrectGigabyteNumber() | ||
{ | ||
var input = "42g"; | ||
|
||
var num = input.Convert(); | ||
Assert.AreEqual(45097156608, num); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters