Exemple #1
0
    public void ProducesCorrectAmountOfEnergy()
    {
        this.energyRepository   = new EnergyRepository();
        this.providerController = new ProviderController(energyRepository);

        List <string> provider1 = new List <string>()
        {
            "Solar",
            "1",
            "100"
        };

        List <string> provider2 = new List <string>()
        {
            "Solar",
            "2",
            "100"
        };

        providerController.Register(provider1);
        providerController.Register(provider2);


        this.providerController.Produce();

        Assert.AreEqual(200, providerController.TotalEnergyProduced);
    }
Exemple #2
0
    public void RegisterProviderValidTest()
    {
        var sb = new StringBuilder();

        sb.AppendLine(providerController.Register("Pressure 40 100".Split()))
        .AppendLine(providerController.Register("Solar 20 100".Split()))
        .AppendLine(providerController.Register("Standart 10 100".Split()));

        var expected = new StringBuilder()
                       .AppendLine("Successfully registered PressureProvider")
                       .AppendLine("Successfully registered SolarProvider")
                       .AppendLine("Successfully registered StandartProvider")
                       .ToString().TrimEnd();

        var actual = sb.ToString().TrimEnd();

        Assert.AreEqual(expected, actual);
    }
Exemple #3
0
    public override string Execute()
    {
        string type = Arguments[1];

        if (type.ToLower() == "harvester")
        {
            return(harvesterController.Register(Arguments.Skip(2).ToArray()));
        }
        return(providerController.Register(Arguments.Skip(2).ToArray()));
    }
Exemple #4
0
    public override string Execute()
    {
        string type   = this.Arguments[0];
        string result = string.Empty;

        if (type == "Harvester")
        {
            result = harvesterController.Register(this.Arguments.Skip(1).ToList());
        }
        else
        {
            result = providerController.Register(this.Arguments.Skip(1).ToList());
        }

        return(result);
    }
Exemple #5
0
    public void CorrectCountEntities()
    {
        this.energyRepository   = new EnergyRepository();
        this.providerController = new ProviderController(energyRepository);

        List <string> provider1 = new List <string>()
        {
            "Pressure",
            "1",
            "100"
        };

        providerController.Register(provider1);


        for (int i = 0; i < 8; i++)
        {
            providerController.Produce();
        }

        Assert.AreEqual(0, providerController.Entities.Count);
    }
Exemple #6
0
    public void RegisterMethod(string name, string id, string energyOutput)
    {
        IList <string> args = new List <string> {
            name, id, energyOutput
        };

        string result = providerController.Register(args);

        Assert.That(result, Is.EqualTo($"Successfully registered {name}Provider"));
    }