예제 #1
0
        public void Editing_A_Runtime_From_Dictionary_Should_Give_A_New_Runtime()
        {
            var runtimemodel = new RuntimeModel();
            var newValue = 0;
            var checkpointid = 0;
            Given("we have a runtime", () =>
            {
                timer.Start();
                checkpointid = timer.GetFirstCheckpointId();
                runtimemodel = timer.AddRuntime(500, checkpointid);
            });

            When("we want to change the runtime", () =>
            {
                timer.EditRuntime(runtimemodel.Id, 0, 1, 32, 20);
                newValue = Convert.ToInt32(timer.CheckpointRuntimes[checkpointid].First().Value);
            });

            Then("the new runtime shouldn't be equal to the previous", () => newValue.ShouldNotBe(runtimemodel.Runtime));
        }
예제 #2
0
파일: TimerModel.cs 프로젝트: heinek/ITimeU
 /// <summary>
 /// Deletes the runtime.
 /// </summary>
 /// <param name="runtime">The runtime.</param>
 public void DeleteRuntime(RuntimeModel runtime)
 {
     CheckpointRuntimes[CurrentCheckpointId].Remove(runtime.Id);
     using (var ctx = new Entities())
     {
         var runtimeToDelete = ctx.Runtimes.Where(runt => runt.RuntimeID == runtime.Id).Single();
         runtimeToDelete.IsDeleted = true;
         ctx.SaveChanges();
     }
 }
예제 #3
0
        public void Deleting_A_Runtime_From_Dictionary_Should_Reduce_The_Dictionary_With_1()
        {
            var runtime = new RuntimeModel();
            var listcount = 0;
            var checkpointid = 0;
            Given("we have a runtimelist", () =>
            {
                timer.Start();
                checkpointid = timer.GetFirstCheckpointId();
                runtime = timer.AddRuntime(300, checkpointid);
                listcount = timer.CheckpointRuntimes[checkpointid].Count;
            });

            When("we want to delete a runtime", () =>
            {
                timer.DeleteRuntime(runtime);
            });

            Then("the runtime list should be rduced with 1", () =>
            {
                timer.CheckpointRuntimes[checkpointid].Count.ShouldBe(listcount - 1);
            });
        }
예제 #4
0
파일: TimerModel.cs 프로젝트: heinek/ITimeU
 /// <summary>
 /// Adds the runtime.
 /// </summary>
 /// <param name="runtimemodel">The runtimemodel.</param>
 public void AddRuntime(RuntimeModel runtimemodel)
 {
     RuntimeModel.Create(runtimemodel.Runtime, runtimemodel.CheckPointId);
     var checkpointRuntimeDic = CheckpointRuntimes[CurrentCheckpointId];
     checkpointRuntimeDic.Add(runtimemodel.Id, runtimemodel.Runtime);
     if (CheckpointRuntimes.ContainsKey(CurrentCheckpointId))
         CheckpointRuntimes[CurrentCheckpointId] = checkpointRuntimeDic;
     else
         CheckpointRuntimes.Add(CurrentCheckpointId, checkpointRuntimeDic);
 }