Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 9416e471 authored by Edouard Mangel's avatar Edouard Mangel
Browse files

Added random test generator

parent 1128b0c1
No related branches found
Tags v1.4.7
No related merge requests found
Showing
with 82 additions and 0 deletions
No preview for this file type
File added
File deleted
File deleted
File deleted
File deleted
File added
File added
File added
No preview for this file type
File added
File added
namespace UnitTests;
public interface IRandomGenerator
{
long Roll();
}
public class ConcreteRandomGenerator : IRandomGenerator
{
public long Roll()
{
return new Random().NextInt64(1, 6);
}
}
\ No newline at end of file
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
File added
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
File added
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NFluent;
namespace UnitTests;
public class DiceRollTest
{
[Fact]
public void ShouldReturn8whenRolled4()
{
var stubGenerator = new StubGenerator(4);
var result = new RandomUsecase(stubGenerator).Roll();
Check.That(8).Equals(result);
}
[Fact]
public void ShouldReturn18whenRolled6()
{
var stubGenerator = new StubGenerator(6);
var result = new RandomUsecase(stubGenerator).Roll();
Check.That(18).Equals(result);
}
}
namespace UnitTests;
internal class RandomUsecase
{
public IRandomGenerator RandomGenerator { get; set; }
public RandomUsecase(IRandomGenerator randomGenerator)
{
RandomGenerator = randomGenerator;
}
public long Roll()
{
long rolledvalue = RandomGenerator.Roll();
if (rolledvalue == 6) {
return 18;
}
return rolledvalue * 2 ;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment