Skip to content

Commit

Permalink
Add and use NFluent library
Browse files Browse the repository at this point in the history
  • Loading branch information
toxis committed Jul 18, 2018
1 parent 982178b commit 6fdfa4a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
7 changes: 4 additions & 3 deletions BaseTests/Asynchronous/AsyncAwaitTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using NFluent;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -22,8 +23,8 @@ public async Task DownloadTest()
{
string destination = Path.Combine(_tempFolder, "README.md");
await DownloadFileAsync(FileToDownload, destination);
Assert.That(File.Exists(destination));
Assert.AreEqual(ComputeMD5File(destination), Md5Hash);
Check.That(File.Exists(destination));
Check.Equals(ComputeMD5File(destination), Md5Hash);
}

[Test]
Expand Down
3 changes: 3 additions & 0 deletions BaseTests/BaseTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<Reference Include="Moq, Version=4.9.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.9.0\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="NFluent, Version=2.3.1.194, Culture=neutral, PublicKeyToken=18828b37b84b1437, processorArchitecture=MSIL">
<HintPath>..\packages\NFluent.2.3.1\lib\net45\NFluent.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.10.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
Expand Down
11 changes: 6 additions & 5 deletions BaseTests/Fixtures/FixtureTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AutoFixture;
using NFluent;
using NUnit.Framework;
using System;
using System.Linq;
Expand All @@ -16,13 +17,13 @@ public void ShouldReplaceDefaultValues()
var entities = fixture.Build<FixtureEntity>()
.Without(e => e.NotFixtureProperty)
.CreateMany(10);
Assert.AreEqual(10, entities.Count());


Check.That(entities).CountIs(10);
foreach (var entity in entities)
{
Assert.NotNull(entity.StringProperty);
Assert.AreNotEqual(0, entity.IntProperty);
Assert.AreEqual(nameof(entity.NotFixtureProperty), entity.NotFixtureProperty);
Check.That(entity.StringProperty).IsNotNull();
Check.That(entity.IntProperty).IsStrictlyPositive().And.IsStrictlyGreaterThan(0);
Check.That(entity.NotFixtureProperty).IsEqualTo(nameof(entity.NotFixtureProperty));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion BaseTests/Moq/MoqTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using Moq;
using NFluent;

namespace BaseTests.Moq
{
Expand All @@ -10,7 +11,7 @@ public class MoqTest
public void MultiplyCalculatorTest()
{
var calculator = Mock.Of<MoqCalculator>(c => c.Multiply(2, 2) == 4);
Assert.AreEqual(4, calculator.Pow2(2));
Check.That(calculator.Pow2(2)).IsEqualTo(4);
// Be sure that Multiply method was called in Pow2 method
Mock.Get(calculator).Verify(c => c.Multiply(2, 2));
}
Expand Down
1 change: 1 addition & 0 deletions BaseTests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<package id="Castle.Core" version="4.3.1" targetFramework="net452" />
<package id="Fare" version="2.1.1" targetFramework="net452" />
<package id="Moq" version="4.9.0" targetFramework="net452" />
<package id="NFluent" version="2.3.1" targetFramework="net452" />
<package id="NUnit" version="3.10.1" targetFramework="net452" />
<package id="NUnit3TestAdapter" version="3.10.0" targetFramework="net452" />
<package id="System.Threading.Tasks.Extensions" version="4.3.0" targetFramework="net452" />
Expand Down

0 comments on commit 6fdfa4a

Please sign in to comment.