コード例 #1
0
ファイル: StateTest.cs プロジェクト: andy-uq/Echo
        public virtual void SetUp()
        {
            var configurationBuilder = new Autofac.ContainerBuilder();

            var fresh = new CreateFreshDatabase();
            fresh.Create(configurationBuilder);

            var resolver = new AutofacResolver(configurationBuilder);

            Database = resolver.Resolve<IDocumentStore>();
            Universe = new MockUniverse();
        }
コード例 #2
0
ファイル: GameUpdate.cs プロジェクト: andy-uq/Echo
        public void Update()
        {
            var world = new MockUniverse();
            var universe = Universe.Builder.Build(world.Universe).Materialise();

            var sol = universe.StarClusters
                .SelectMany(x => x.SolarSystems)
                .Single(x => x.Id == world.SolarSystem.ObjectId);

            var earth = sol.Satellites
                .Single(x => x.Id == world.Earth.ObjectId);

            var game = new Game(universe, u => Orbit(Satellites(u)));

            var ticksRemaining = game.Update();
            ticksRemaining.ShouldBeGreaterThan(0);

            earth.Position.LocalCoordinates.ShouldNotBe(world.Earth.LocalCoordinates);
        }
コード例 #3
0
ファイル: PositionTests.cs プロジェクト: andy-uq/Echo
        public void GetSolarSystem()
        {
            var s = new MockUniverse();
            Assert.That(s.Universe.StarClusters, Is.Not.Empty);

            var builder = Universe.Builder.Build(s.Universe);
            builder.Add(Corporation.Builder.Build(s.MSCorp));

            var u = builder.Materialise();

            u.StarClusters.ShouldNotBeEmpty();
            u.SolarSystems().ShouldNotBeEmpty();

            var sol = u.SolarSystems().Single(x => x.Id == s.SolarSystem.ObjectId);
            var earth = u.Planets().Single(p => p.Id == s.Earth.ObjectId);

            earth.Position.GetSolarSystem().ShouldBe(sol);

            var ship = new Ship {Position = new Position(earth, new Vector(1, 1))};
            ship.Position.GetSolarSystem().ShouldBe(sol);
        }
コード例 #4
0
ファイル: Orbit.cs プロジェクト: andy-uq/Echo
        public void EarthOrbit()
        {
            var world = new MockUniverse();
            var universe = Universe.Builder.Build(world.Universe).Materialise();

            var sol = universe.StarClusters
                .SelectMany(x => x.SolarSystems)
                .Single(x => x.Id == world.SolarSystem.ObjectId);

            var earth = sol.Satellites
                .Single(x => x.Id == world.Earth.ObjectId);

            var context = new TickContext(0) { ElapsedTicks = 60 * 60 * 5 };
            var orbiter = new Orbiter(sol);
            var orbitRadius = earth.Position.LocalCoordinates.Magnitude;

            for (var i = 0; i < 12*21; i++)
            {
                orbiter.Orbit(context);
                Console.WriteLine("{0}: {1:n}", i, earth.Position.LocalCoordinates * 1e-5);

                earth.Position.LocalCoordinates.Magnitude.ShouldBe(orbitRadius, Units.Tolerance*100);
            }
        }
コード例 #5
0
ファイル: ManufacturingTests.cs プロジェクト: andy-uq/Echo
        public void CreateItemFactory()
        {
            _universe = new MockUniverse();

            _itemFactory = new Moq.Mock<IItemFactory>(MockBehavior.Strict);

            SetupItem(_universe.BluePrint);
            SetupItem(_universe.ShipBluePrint);

            var builder = Echo.Structures.Manufactory.Builder.For(_universe.Manufactory).Build(null);
            builder.Add(Corporation.Builder.Build(_universe.MSCorp));

            _manufactory = builder.Materialise();
        }
コード例 #6
0
ファイル: UndockTask.cs プロジェクト: andy-uq/Echo
        public void SetUp()
        {
            _universe = new MockUniverse();

            var mock = new Moq.Mock<ILocationServices>();
            mock.Setup(x => x.GetExitPosition(It.IsAny<ILocation>())).Returns<ILocation>(l => l.Position.LocalCoordinates);

            _task = new UndockShipTask(mock.Object);
        }