67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using Fluxor;
|
|
using KoogleApp.Games;
|
|
using KoogleApp.Games.Training;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using FluentAssertions;
|
|
using KoogleApp.Store.Game.ThrowPanel;
|
|
using Moq;
|
|
|
|
namespace Koogle.Tests.GameTraining
|
|
{
|
|
public class GameTrainingServiceTest
|
|
{
|
|
|
|
private readonly ServiceProvider _serviceProvider;
|
|
private readonly Mock<IDispatcher> _mockDispatcher;
|
|
|
|
public GameTrainingServiceTest()
|
|
{
|
|
var services = new ServiceCollection();
|
|
|
|
// Deine Services registrieren wie in Program.cs
|
|
services.AddScoped<IGameService, GameTrainingService>();
|
|
//services.AddSingleton<IConfiguration>(new ConfigurationBuilder()
|
|
// .AddInMemoryCollection(new Dictionary<string, string>
|
|
// {
|
|
// ["Setting"] = "TestValue"
|
|
// })
|
|
// .Build());
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
|
|
|
_mockDispatcher = new Mock<IDispatcher>();
|
|
}
|
|
|
|
[Fact]
|
|
public void ServiceWorksCorrectly()
|
|
{
|
|
// Arrange
|
|
var service = _serviceProvider.GetRequiredService<IGameService>();
|
|
|
|
// Act & Assert
|
|
var result = service.InitGameModel(GetSetup(), _mockDispatcher.Object) as TrainingGameModel;
|
|
result.Throws.Count.Should().Be(3);
|
|
}
|
|
|
|
private IGameSetupModel GetSetup()
|
|
{
|
|
return new TrainingSetupState()
|
|
{
|
|
DayId = 1,
|
|
ThrowMode = ThrowMode.Reposition,
|
|
ThrowsPerRound = 3,
|
|
Participants = new int[] { 1, 2, 3 },
|
|
ParticipantsMode = ParticipantsMode.GameLogic,
|
|
KnownGameType = "Training"
|
|
};
|
|
}
|
|
}
|
|
|
|
}
|