100coding
4/7/2017 - 2:11 AM

0F63846E-925F-4BC0-BDB6-64C7F8E63C87

0F63846E-925F-4BC0-BDB6-64C7F8E63C87

using System.Linq;
using Zenject;
using NUnit.Framework;
using UnityEngine;
using Zenject.Asteroids;

[TestFixture]
public class TestAsteroidManager : ZenjectIntegrationTestFixture
{
    [SetUp]
    public void Common_install()
    {
        GameSettingsInstaller.InstallFromResource(Container);
        
        var game_setting = Container.Resolve<GameInstaller.Settings>();
        Container.Bind<AsteroidManager>().AsSingle();
        Container.BindFactory<Asteroid, Asteroid.Factory>()
            .FromComponentInNewPrefab(game_setting.AsteroidPrefab);
        Container.Bind<Camera>().WithId("Main").FromNewComponentOnNewGameObject();
        Container.Bind<LevelHelper>().AsSingle();

        Initialize();
    }

    [Inject] private AsteroidManager asteroid_manager;

    [Inject] private AsteroidManager.Settings asteroid_manager_settings;

    [Test]
    [ValidateOnly]
    public void Test_validate()
    { }

    [Test]
    public void Test_initial_spawns()
    {
        this.asteroid_manager.Start();

        Assert.AreEqual(this.asteroid_manager.Asteroids.Count(), this.asteroid_manager_settings.startingSpawns);
    }

    [Test]
    public void Test_spawn_next()
    {
        this.asteroid_manager.Start();
        this.asteroid_manager.SpawnNext();

        Assert.AreEqual(this.asteroid_manager.Asteroids.Count(), this.asteroid_manager_settings.startingSpawns + 1);
    }
}