public void SourceLifecycleMethods_CreateAndDeleteObjects() { var source = new Mock <ISource>(MockBehavior.Strict); source.Setup(_ => _.Dispose()); _mockFactory.Setup(_ => _.Create <ISource>()).Returns(source.Object); _target.CreateSource(); var result = _target.CreateSource(); _target.DeleteSource(result); source.Verify(_ => _.Dispose(), Times.Once); }
public void Attach() { _scene.Init(); _physicsContainer.Gravity = new Vector3(0, -800, 0); var entity = _scene.CreateEntity(); _scene.AddComponent(entity, new CameraComponent { Camera = _camera, Active = true }); var texture = _factory.Create <ITexture2D>(); texture.SetData("Assets/landscape.jpeg"); var soundBuffer = _soundManager.CreateSoundBuffer(); soundBuffer.SetData("Assets/jump.wav"); var source = _soundManager.CreateSource(); source.Gain = 1f; entity = _scene.CreateEntity(); _scene.AddComponent(entity, new PositionComponent { Position = new Vector3(-400, -100, 0) }); _scene.AddComponent(entity, new SizeComponent { Width = 100, Height = 100 }); _scene.AddComponent(entity, new TextureComponent { Texture = texture }); var physicsComponent = new PhysicsComponent(); _scene.AddComponent(entity, physicsComponent); var sourceComponent = new SourceComponent { Source = source, SoundBuffer = soundBuffer }; _scene.AddComponent(entity, sourceComponent); _scene.AddComponent(entity, new ControlScript(physicsComponent, sourceComponent)); entity = _scene.CreateEntity(); _scene.AddComponent(entity, new PositionComponent { Position = new Vector3(0, -360, 0) }); _scene.AddComponent(entity, new SizeComponent { Width = 1280, Height = 10 }); _scene.AddComponent(entity, new PhysicsComponent { Fixed = true }); entity = _scene.CreateEntity(); _scene.AddComponent(entity, new PositionComponent { Position = new Vector3(0, -200, 0) }); _scene.AddComponent(entity, new SizeComponent { Width = 600, Height = 10 }); _scene.AddComponent(entity, new PhysicsComponent { Fixed = true }); entity = _scene.CreateEntity(); _scene.AddComponent(entity, new PositionComponent { Position = new Vector3(420, -95, 0), Rotation = new Vector3(0, 0, 45) }); _scene.AddComponent(entity, new SizeComponent { Width = 300, Height = 10 }); _scene.AddComponent(entity, new PhysicsComponent { Fixed = true }); entity = _scene.CreateEntity(); _scene.AddComponent(entity, new PositionComponent { Position = new Vector3(0, -100, 0) }); _scene.AddComponent(entity, new SizeComponent { Width = 10, Height = 300 }); _scene.AddComponent(entity, new PhysicsComponent { Fixed = true }); _physicsContainer.Start(144, _scene.EntityContainer); _soundManager.Start(60, _scene.EntityContainer); }