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

samsmithnz / SatisfactoryTree / 17365514447

01 Sep 2025 01:56AM UTC coverage: 39.13% (+2.6%) from 36.569%
17365514447

push

github

web-flow
Merge pull request #268 from samsmithnz/copilot/fix-263

Implement production planning system for specific products in Satisfactory WinForms app

466 of 631 branches covered (73.85%)

Branch coverage included in aggregate %.

159 of 180 new or added lines in 4 files covered. (88.33%)

1235 of 3716 relevant lines covered (33.23%)

2553.36 hits per line

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

76.53
/src/SatisfactoryTree/Services/ProductionPlanningService.cs
1
using SatisfactoryTree.Models;
2

3
namespace SatisfactoryTree.Services
4
{
5
    public class ProductionPlanningService
6
    {
7
        public ProductionPlanningService()
6✔
8
        {
6✔
9
            Factories = new Dictionary<string, Factory>();
6✔
10
            // Create default factory
11
            AddFactory("default", "Main Factory");
6✔
12
        }
6✔
13

14
        public Dictionary<string, Factory> Factories { get; set; }
61✔
15

16
        public Factory AddFactory(string id, string name = "")
17
        {
12✔
18
            if (Factories.ContainsKey(id))
12!
NEW
19
            {
×
NEW
20
                throw new ArgumentException($"Factory with ID '{id}' already exists.");
×
21
            }
22

23
            var factory = new Factory(id, name);
12✔
24
            Factories[id] = factory;
12✔
25
            return factory;
12✔
26
        }
12✔
27

28
        public void RemoveFactory(string id)
29
        {
1✔
30
            if (id == "default")
1!
31
            {
1✔
32
                throw new ArgumentException("Cannot remove the default factory.");
1✔
33
            }
NEW
34
            Factories.Remove(id);
×
NEW
35
        }
×
36

37
        public Factory? GetFactory(string id)
38
        {
13✔
39
            return Factories.ContainsKey(id) ? Factories[id] : null;
13!
40
        }
13✔
41

42
        public List<Factory> GetAllFactories()
NEW
43
        {
×
NEW
44
            return Factories.Values.ToList();
×
NEW
45
        }
×
46

47
        public ProductionGoal AddProductionGoal(string itemName, decimal targetQuantity, string factoryId = "default")
48
        {
2✔
49
            var factory = GetFactory(factoryId);
2✔
50
            if (factory == null)
2!
NEW
51
            {
×
NEW
52
                throw new ArgumentException($"Factory with ID '{factoryId}' not found.");
×
53
            }
54

55
            return factory.AddProductionGoal(itemName, targetQuantity);
2✔
56
        }
2✔
57

58
        public void ProcessProduction(string itemName, decimal quantity, string factoryId = "default")
59
        {
3✔
60
            var factory = GetFactory(factoryId);
3✔
61
            if (factory == null)
3!
NEW
62
            {
×
NEW
63
                throw new ArgumentException($"Factory with ID '{factoryId}' not found.");
×
64
            }
65

66
            factory.ProcessProduction(itemName, quantity);
3✔
67
        }
3✔
68

69
        public List<ProductionGoal> GetAllActiveGoals()
70
        {
1✔
71
            return Factories.Values.SelectMany(f => f.GetActiveGoals()).ToList();
2✔
72
        }
1✔
73

74
        public List<ProductionGoal> GetAllCompletedGoals()
75
        {
1✔
76
            return Factories.Values.SelectMany(f => f.GetCompletedGoals()).ToList();
2✔
77
        }
1✔
78

79
        public void TransferItemsBetweenFactories(string fromFactoryId, string toFactoryId, string itemName, decimal quantity)
80
        {
1✔
81
            var fromFactory = GetFactory(fromFactoryId);
1✔
82
            var toFactory = GetFactory(toFactoryId);
1✔
83

84
            if (fromFactory == null || toFactory == null)
1!
NEW
85
            {
×
NEW
86
                throw new ArgumentException("One or both factories not found.");
×
87
            }
88

89
            if (fromFactory.Storage.RemoveItem(itemName, quantity))
1!
90
            {
1✔
91
                toFactory.Storage.AddItem(itemName, quantity);
1✔
92
            }
1✔
93
            else
NEW
94
            {
×
NEW
95
                throw new InvalidOperationException($"Insufficient {itemName} in factory {fromFactoryId} storage.");
×
96
            }
97
        }
1✔
98

99
        public Dictionary<string, decimal> GetTotalStorage()
100
        {
1✔
101
            var totalStorage = new Dictionary<string, decimal>();
1✔
102

103
            foreach (var factory in Factories.Values)
9✔
104
            {
3✔
105
                foreach (var item in factory.Storage.GetAllItems())
17✔
106
                {
4✔
107
                    if (totalStorage.ContainsKey(item.Key))
4✔
108
                    {
2✔
109
                        totalStorage[item.Key] += item.Value;
2✔
110
                    }
2✔
111
                    else
112
                    {
2✔
113
                        totalStorage[item.Key] = item.Value;
2✔
114
                    }
2✔
115
                }
4✔
116
            }
3✔
117

118
            return totalStorage;
1✔
119
        }
1✔
120
    }
121
}
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