public static void Main(string[] args) { var ecs = new ECS(28, new Heater(), new TempSensor()); ecs.Regulate(); ecs.SetThreshold(20); ecs.Regulate(); }
public static void Main(string[] args) { var ecs = new ECS(28, new TempSensor(), new Heater()); ecs.Regulate(); ecs.SetThreshold(20); ecs.Regulate(); }
public static void Main(string[] args) { var ecs = new ECS(28); ecs.Regulate(); ecs.SetThreshold(20); ecs.Regulate(); }
public void ECS_CanRegulateThr24BelowT25_HeaterTurnedOff() { // Arrange var fakeHeater = new FakeHeater(); var uut = new ECS(24, new FakeTempSensor(), fakeHeater, new FakeWindow()); //Act uut.Regulate(); Assert.That(fakeHeater.TurnedOn, Is.False); }
public void Expection_TempUnder0() { var fh = new FakeHeater(); var ts = new FakeTempSensor(); var uut = new ECS(25, ts, fh); ts.Temp = -2; Assert.Throws(Is.TypeOf <ArgumentException>(), () => uut.Regulate()); }
public static void Main(string[] args) { var ecs = new ECS(28, new TempSensor.TempSensor(), new Heater.Heater()); ecs.Regulate(); ecs.SetThreshold(20); ecs.Regulate(); System.Console.ReadKey(); }
public void ECS_CanRegulateThr26AboveT25_HeaterTurnedOn() { // Arrange var fakeHeater = new FakeHeater(); var uut = new ECS(26, new FakeTempSensor(), fakeHeater, new FakeWindow()); //Act uut.Regulate(); Assert.That(fakeHeater.TurnedOn, Is.True); }
public static void Main(string[] args) { var ecs = new ECS(28, new TempSensor()); ecs.Regulate(); ecs.SetThreshold(20); ecs.Regulate(); // init commit test }
public static void Main(string[] args) { ITempSensor tempSensor = new TempSensor(); IHeater heater = new Heater(); var ecs = new ECS(28, tempSensor, heater); ecs.Regulate(); ecs.SetThreshold(20); ecs.Regulate(); }
public static void Main(string[] args) { // Because of constructor injection, allocation is done in the constructor. // Ability to chose which derivatives one wants to work with var ecs = new ECS(28, new TempSensor(), new Heater()); ecs.Regulate(); ecs.SetThreshold(20); ecs.Regulate(); }
public void Regulate_HighTemp_HeaterIsTurnedOn() { var fh = new FakeHeater(); var ts = new FakeTempSensor(); var uut = new ECS(25, ts, fh); ts.Temp = 27; uut.Regulate(); Assert.That(fh.WasTurnOffCalled, Is.EqualTo(true)); }
public static void Main(string[] args) { //Create dependencies ITempSensor _tempSensor = new TempSensor(); IHeater _heater = new Heater(); //Create ECS sytem class var ecs = new ECS(28, _tempSensor, _heater); ecs.Regulate(); ecs.SetThreshold(20); }
public void RunSelfTest_StubsSetToXandY_ExpectZ(bool X, bool Y, bool Z) { StubTempSensor sts = new StubTempSensor(0); sts.RunSelftestBool = X; StubHeater sh = new StubHeater(); sh.RunSelftestBool = Y; uut = new ECS(sts, sh, 10); bool result = uut.RunSelfTest(); Assert.That(result, Is.EqualTo(Z)); }
public void Regulate_TemperatureOverThreshold_HeaterTurnOnNotCalled(int threshold, int temperature, int onCountResult) { uut = new ECS(threshold); MockHeater TestHeater = new MockHeater(); StubTempSensor TestSensor = new StubTempSensor(temperature); uut.TempSensor_ = TestSensor; uut.Heater_ = TestHeater; uut.Regulate(); Assert.That(onCountResult, Is.EqualTo(TestHeater.TurnOnCount)); }
/// <summary> /// Creates a new instance of a debri entity. /// </summary> /// <param name="spawn">Spawn location.</param> public Debri(Vector2 spawn) : base(ECS.GetNextId()) { Random random = new Random(); // Components Components = new IComponent[] { new PositionComponent() { Position = spawn, Momentum = Blackhole.GetInitialMomentum(spawn), AngularMomentum = random.Next(-40, 40), Direction = random.Next(0, 360), CollisionMask = new CollisionMaskCircle( spawn, 32 ) }, new AnimationComponent() { Sprite = "Objects/Resources/Debri" }, new AffectedByBlackholeComponent() { Entity = this }, new WorldComponent() { Entity = this }, new CombatComponent() { Health = 1, MaxHealth = 1, Armour = 0, MaxArmour = 0, Entity = this }, new ResourceComponent() { Value = 50 } }; // Link as required ((AffectedByBlackholeComponent)Components[2]).Position = Position; ((WorldComponent)Components[3]).PositionComponent = Position; // Register components RegisterComponents(); }
public void Setup() { // Create the fake stubs and mocks //_Heater = new FakeHeater(); //_fakeTempSensor = new FakeTempSensor(); //_fakeWindow = new FakeWindow(); // Inject them into the uut via the constructor //_uut = new ECS(_fakeTempSensor, _Heater, _fakeWindow, 25, 28); _Heater = Substitute.For <IHeater>(); _fakeTempSensor = Substitute.For <ITempSensor>(); _fakeWindow = Substitute.For <IWindow>(); _uut = new ECS(_fakeTempSensor, _Heater, _fakeWindow, 20, 30); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = false; _ecs = new ECS(); _ecs.InitiliseSettings(); graphics.PreferredBackBufferWidth = _ecs.Settings.Width; // set this value to the desired width of your window graphics.PreferredBackBufferHeight = _ecs.Settings.Height; // set this value to the desired height of your window graphics.ApplyChanges(); IsMouseVisible = true; base.Initialize(); }
/// <summary> /// Creates a new instance of a projectile. /// </summary> /// <param name="x">Initial x position.</param> /// <param name="y">Initial y position.</param> /// <param name="direction">Initial direction.</param> /// <param name="team">Team who owns projectile.</param> /// <param name="owner">Player who owns projectile.</param> public Projectile(float x, float y, float direction, Team team = null, Entity owner = null) : base(ECS.GetNextId()) { // Todo(Chris): Get rid of magic numbers. Components = new IComponent[] { new PositionComponent() { Position = new Vector2(x, y), Direction = direction, Momentum = new Vector2( (float)Math.Cos(MathHelper.ToRadians(direction)), (float)Math.Sin(MathHelper.ToRadians(direction)) ) * 1000, AngularMomentum = 0, CollisionMask = new CollisionMaskLine( new Vector2(x, y), 20, direction ) }, new AnimationComponent() { Sprite = "Objects/Weapons/line_projectile" }, new WorldComponent(), new LifetimeComponent() { LifetimeRemaining = 1000 }, new ProjectileComponent() { Team = team } }; // Link components: World.Entity = this; World.PositionComponent = Position; Lifetime.Entity = this; ProjectileComponent.Entity = this; ProjectileComponent.Position = Position; ProjectileComponent.World = World; Owner = owner; // Register components RegisterComponents(); }
public void TestSelfTest(bool Heater, bool Temp, bool expeted) { //Arrange var subHeater = NSubstitute.Substitute.For <IHeater>(); var subTemp = NSubstitute.Substitute.For <ITempSensor>(); var uut = new ECS(subTemp, subHeater, 3); //Arrange stub subHeater.RunSelfTest().Returns(Heater); subTemp.RunSelfTest().Returns(Temp); //Act / Assert Assert.That(uut.RunSelfTest(), Is.EqualTo(expeted)); }
/// <summary> /// Creates a Mothership entity. /// </summary> public Mothership(int x, int y, Team team) : base(ECS.GetNextId()) { // Register components. Components = new IComponent[] { new PositionComponent() { Position = new Vector2(x, y), Momentum = Blackhole.GetInitialMomentum( new Vector2(x, y) ), Direction = 0, AngularMomentum = 0, CollisionMask = new CollisionMaskCircle( new Vector2(x, y), 128 ) }, new WorldComponent(), new AnimationComponent() { Sprite = "Objects/Ships/Mothership" }, new AffectedByBlackholeComponent() { Entity = this }, new TeamComponent() { Team = team }, new ResourceComponent() { Value = 0 } }; // Link components World.Entity = this; World.PositionComponent = Position; ((AffectedByBlackholeComponent)Components[3]).Position = Position; Team.Team.Mothership = this; // Register components RegisterComponents(); }
public void TestRegulate_WithDefirentTemp_ButStaticThresholdAt13(int GetTempReturn, int expectedOutput) { //Arrange var subHeater = NSubstitute.Substitute.For <IHeater>(); var subTemp = NSubstitute.Substitute.For <ITempSensor>(); var uut = new ECS(subTemp, subHeater, 13); subTemp.GetTemp().Returns(GetTempReturn); //Act uut.Regulate(); //Assert subHeater.Received(expectedOutput).TurnOn(); }
public void GetThreshold_Test(int thr) { var uut = new ECS(thr, new TestTempSensor(), new TestHeater()); Assert.That(uut.GetThreshold(), Is.EqualTo(thr)); }
public void RunSelfTest_HeaterAndTempSensor_ReturnsTrue() { var uut = new ECS(28, new TestTempSensor(), new TestHeater()); Assert.That(uut.RunSelfTest, Is.EqualTo(true)); }
public void AddBody(ECS.Components.PhysicsBody body) { world.AddBody(body.Body); }
public void Setup() { int threshold = 32; _uut = new ECS(threshold, _fake); }
public void ECS_RunSelfTest_ReturnsTrue() { var uut = new ECS(0, new FakeTempSensor(), new FakeHeater(), new FakeWindow()); Assert.That(uut.RunSelfTest, Is.True); }
public void ECS_GetCurTemp_Returns0() { var uut = new ECS(0, new FakeTempSensor(), new FakeHeater(), new FakeWindow()); Assert.That(uut.GetCurTemp(), Is.EqualTo(0)); }
public void ECS_Ctor_Inject_NoThrow() { var uut = new ECS(10, new FakeTempSensor(), new FakeHeater(), new FakeWindow()); }
public void SetUp() { _heater = Substitute.For <IHeater>(); _tempSensor = Substitute.For <ITempSensor>(); _uut = new ECS(24, _heater, _tempSensor); }
public void Setup() { _heater = Substitute.For <IHeater>(); _tempSensor = Substitute.For <ITempSensor>(); _uut = new ECS(_tempSensor, _heater, 25); }
public void Setup() { _fakeHeater = Substitute.For <IHeater>(); _fakeTempSensor = Substitute.For <ITempSensor>(); _uut = new ECS(20, _fakeHeater, _fakeTempSensor); }
public void Setup() { _fakeHeater = new fakeHeater(); _fakeTempSensor = new fakeTempSensor(); _uut = new ECS(20, _fakeHeater, _fakeTempSensor); }
public void Setup() { _uut = new ECS(15, _tempSensor = new TempSensor(), _heater = new FakeHeater()); }