public async Task BotProcessingFactory_Process_With_Valid_Script_Should_Register_Correct_Move()
        {
            // Arrange
            var botLogic             = new Mock <IBotLogic>();
            var botScriptCompiler    = new BotScriptCompiler();
            var botScriptCache       = new BotScriptCache();
            var logger               = new Mock <ILogger <BotProcessingFactory> >();
            var botProcessingFactory = new BotProcessingFactory(
                botLogic.Object, botScriptCompiler, botScriptCache, logger.Object);
            var arena = new ArenaDto {
                Width = 4, Height = 3
            };
            var bot = new BotDto {
                Id = Guid.NewGuid()
            };
            var bots    = new List <BotDto>(new[] { bot });
            var context = ProcessingContext.Build(arena, bots);

            context.AddBotProperties(bot.Id, BotProperties.Build(bot, arena, bots));
            var botScript = "WalkForward();".Base64Encode();

            // Mock
            botLogic.Setup(x => x.GetBotScript(It.IsAny <Guid>())).ReturnsAsync(botScript);

            // Act
            await botProcessingFactory.Process(bot, context);

            // Assert
            context.GetBotProperties(bot.Id).CurrentMove.Should().Be(PossibleMoves.WalkForward);
        }
    public void BotScriptCache_ScriptStored_For_Unknown_BotId_Should_Return_False()
    {
        // Arrange
        var botScriptCache = new BotScriptCache();

        // Act
        var result = botScriptCache.ScriptStored(Guid.NewGuid());

        // Assert
        result.Should().BeFalse();
    }
    public void BotScriptCache_LoadScript_For_Known_BotId_Should_Throw_Exception()
    {
        // Arrange
        var botScriptCache = new BotScriptCache();

        // Act
        botScriptCache.Invoking(x => x.LoadScript(Guid.NewGuid()))

        // Assert
        .Should().Throw <ArgumentException>();
    }
    public void BotScriptCache_ScriptStored_For_Known_BotId_Should_Return_True()
    {
        // Arrange
        var botScriptCache = new BotScriptCache();
        var botId          = Guid.NewGuid();

        botScriptCache.StoreScript(botId, CSharpScript.Create("").CreateDelegate());

        // Act
        var result = botScriptCache.ScriptStored(botId);

        // Assert
        result.Should().BeTrue();
    }
    public void BotScriptCache_ClearScript_For_Known_BotId_Should_Succeed()
    {
        // Arrange
        var botScriptCache = new BotScriptCache();
        var botId          = Guid.NewGuid();
        var script         = CSharpScript.Create("");

        botScriptCache.StoreScript(botId, script.CreateDelegate());

        // Act
        botScriptCache.ClearScript(botId);

        // Assert
        botScriptCache.ScriptStored(botId).Should().BeFalse();
    }
        public void BotScriptCache_LoadScript_For_Known_BotId_Should_Return()
        {
            // Arrange
            var botScriptCache = new BotScriptCache();
            var botId          = Guid.NewGuid();
            var script         = CSharpScript.Create("");

            botScriptCache.StoreScript(botId, script);

            // Act
            var result = botScriptCache.LoadScript(botId);

            // Assert
            result.Should().Be(script);
        }