• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

KSP-CKAN / CKAN / 15655026327

14 Jun 2025 06:40PM UTC coverage: 27.152% (-3.2%) from 30.329%
15655026327

Pull #4392

github

web-flow
Merge bb1dadfef into 1b4a54286
Pull Request #4392: Writethrough when saving files, add Netkan tests

3703 of 12085 branches covered (30.64%)

Branch coverage included in aggregate %.

19 of 32 new or added lines in 18 files covered. (59.38%)

9 existing lines in 7 files now uncovered.

8041 of 31168 relevant lines covered (25.8%)

0.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/Core/Types/TimeLog.cs
1
using System;
2
using System.IO;
3
using System.Diagnostics;
4

5
using Newtonsoft.Json;
6
using CKAN.Extensions;
7

8
namespace CKAN
9
{
10
    [JsonObject(MemberSerialization.OptIn)]
11
    public class TimeLog
12
    {
13
        [JsonProperty("time", NullValueHandling = NullValueHandling.Ignore)]
14
        public TimeSpan Time;
15

16
        public static string GetPath(string dir)
17
            => Path.Combine(dir, filename);
2✔
18

19
        public static TimeLog? Load(string path)
20
        {
2✔
21
            try
22
            {
2✔
23
                return JsonConvert.DeserializeObject<TimeLog>(File.ReadAllText(path));
2✔
24
            }
25
            catch (FileNotFoundException)
2✔
26
            {
2✔
27
                return null;
2✔
28
            }
29
        }
2✔
30

31
        public void Save(string path)
32
        {
×
NEW
33
            JsonConvert.SerializeObject(this, Formatting.Indented)
×
34
                       .WriteThroughTo(path);
UNCOV
35
        }
×
36

37
        public override string ToString()
38
            => Time.TotalHours.ToString("N1");
×
39

40
        private readonly Stopwatch playTime = new Stopwatch();
2✔
41

42
        public void Start()
43
        {
×
44
            playTime.Restart();
×
45
        }
×
46

47
        public void Stop(string dir)
48
        {
×
49
            if (playTime.IsRunning)
×
50
            {
×
51
                playTime.Stop();
×
52
                Time += playTime.Elapsed;
×
53
                Save(GetPath(dir));
×
54
            }
×
55
        }
×
56

57
        private const string filename = "playtime.json";
58
    }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc