public void TestRemoveFramesBefore() { var actor = new Actor(new Scene(), 1, 0); var value = new VInt16(actor, 1); value.AddStepFrame(actor.StartTime, 0); Assert.Throws <ArgumentException>(() => value.RemoveFramesBefore(1)); value.AddStepFrame(10, 5); value.Interpolate(5); value.RemoveFramesBefore(4); Assert.AreEqual(0, value.GetValue(4)); Assert.AreEqual(0, value.GetValue(5)); Assert.AreEqual(0, value.GetValue(9)); Assert.AreEqual(5, value.GetValue(10)); Assert.AreEqual(5, value.GetValue(11)); value.AddLinearFrame(20, 15); value.Interpolate(12); value.RemoveFramesBefore(11); Assert.AreEqual(7, value.GetValue(11)); Assert.AreEqual(7, value.GetValue(12)); Assert.AreEqual(8, value.GetValue(13)); Assert.AreEqual(14, value.GetValue(19)); Assert.AreEqual(15, value.GetValue(20)); }
protected Variable <short> AddInt16(Actor actor, int id) { var variable = new VInt16(actor, id); actor.AddVariable(variable); return(variable); }
public Variable <short> AddInt16(int id, short value) { if (this.actor == null) { throw new InvalidOperationException("Cannot add variable after this.actor initialized"); } var state = new RecordState(); var variable = new VInt16(this.actor, id, state); variable.AddStepFrame(this.actor.StartTime, value); state.OnChange(this.actor.StartTime); this.actor.AddVariable(variable); return(variable); }
public void TestRemoveFramesAfter() { var actor = new Actor(new Scene(), 1, 0); var value = new VInt16(actor, 1); value.AddStepFrame(actor.StartTime, 0); Assert.Throws<ArgumentException>(() => value.RemoveFramesAfter(-1)); value.AddStepFrame(10, 5); value.Interpolate(9); value.RemoveFramesAfter(10); Assert.AreEqual(0, value.GetValue(8), 0); Assert.AreEqual(0, value.GetValue(9), 0); Assert.AreEqual(0, value.GetValue(10), 0); value.AddLinearFrame(19, 10); value.Interpolate(17); value.RemoveFramesAfter(18); Assert.AreEqual(7, value.GetValue(16)); Assert.AreEqual(8, value.GetValue(17)); Assert.AreEqual(8, value.GetValue(18)); }
public void TestAddFrames() { var actor = new Actor(new Scene(), 1, 0); var value = new VInt16(actor, 1); value.AddStepFrame(actor.StartTime, -10); Assert.Throws<ArgumentException>(() => value.GetValue(-1)); Assert.AreEqual(-10, value.GetValue(0)); Assert.AreEqual(-10, value.GetValue(1)); value.AddStepFrame(10, 5); Assert.AreEqual(-10, value.GetValue(0)); Assert.AreEqual(-10, value.GetValue(9)); Assert.AreEqual(5, value.GetValue(10)); Assert.AreEqual(5, value.GetValue(11)); value.AddLinearFrame(20, 15); Assert.AreEqual(5, value.GetValue(10)); Assert.AreEqual(6, value.GetValue(11)); Assert.AreEqual(14, value.GetValue(19)); Assert.AreEqual(15, value.GetValue(20)); Assert.AreEqual(15, value.GetValue(21)); }
public void TestRemoveFramesAfter() { var actor = new Actor(new Scene(), 1, 0); var value = new VInt16(actor, 1); value.AddStepFrame(actor.StartTime, 0); Assert.Throws <ArgumentException>(() => value.RemoveFramesAfter(-1)); value.AddStepFrame(10, 5); value.Interpolate(9); value.RemoveFramesAfter(10); Assert.AreEqual(0, value.GetValue(8), 0); Assert.AreEqual(0, value.GetValue(9), 0); Assert.AreEqual(0, value.GetValue(10), 0); value.AddLinearFrame(19, 10); value.Interpolate(17); value.RemoveFramesAfter(18); Assert.AreEqual(7, value.GetValue(16)); Assert.AreEqual(8, value.GetValue(17)); Assert.AreEqual(8, value.GetValue(18)); }
public void TestAddFrames() { var actor = new Actor(new Scene(), 1, 0); var value = new VInt16(actor, 1); value.AddStepFrame(actor.StartTime, -10); Assert.Throws <ArgumentException>(() => value.GetValue(-1)); Assert.AreEqual(-10, value.GetValue(0)); Assert.AreEqual(-10, value.GetValue(1)); value.AddStepFrame(10, 5); Assert.AreEqual(-10, value.GetValue(0)); Assert.AreEqual(-10, value.GetValue(9)); Assert.AreEqual(5, value.GetValue(10)); Assert.AreEqual(5, value.GetValue(11)); value.AddLinearFrame(20, 15); Assert.AreEqual(5, value.GetValue(10)); Assert.AreEqual(6, value.GetValue(11)); Assert.AreEqual(14, value.GetValue(19)); Assert.AreEqual(15, value.GetValue(20)); Assert.AreEqual(15, value.GetValue(21)); }
public Variable<short> AddInt16(int id, short value) { if (this.actor == null) throw new InvalidOperationException("Cannot add variable after this.actor initialized"); var state = new RecordState(); var variable = new VInt16(this.actor, id, state); variable.AddStepFrame(this.actor.StartTime, value); state.OnChange(this.actor.StartTime); this.actor.AddVariable(variable); return variable; }
public void TestRemoveFramesBefore() { var actor = new Actor(new Scene(), 1, 0); var value = new VInt16(actor, 1); value.AddStepFrame(actor.StartTime, 0); Assert.Throws<ArgumentException>(() => value.RemoveFramesBefore(1)); value.AddStepFrame(10, 5); value.Interpolate(5); value.RemoveFramesBefore(4); Assert.AreEqual(0, value.GetValue(4)); Assert.AreEqual(0, value.GetValue(5)); Assert.AreEqual(0, value.GetValue(9)); Assert.AreEqual(5, value.GetValue(10)); Assert.AreEqual(5, value.GetValue(11)); value.AddLinearFrame(20, 15); value.Interpolate(12); value.RemoveFramesBefore(11); Assert.AreEqual(7, value.GetValue(11)); Assert.AreEqual(7, value.GetValue(12)); Assert.AreEqual(8, value.GetValue(13)); Assert.AreEqual(14, value.GetValue(19)); Assert.AreEqual(15, value.GetValue(20)); }