Ejemplo n.º 1
0
        public void CreateSampleWorkorders()
        {
            var workFile = System.IO.Path.Combine("create-work-test", "workorders.csv");

            if (!System.IO.Directory.Exists("create-work-test"))
            {
                System.IO.Directory.CreateDirectory("create-work-test");
            }
            if (System.IO.File.Exists(workFile))
            {
                System.IO.File.Delete(workFile);
            }
            var booking = new BlackMaple.CSVOrders.WorkorderCSV();

            booking.CSVBasePath = "create-work-test";
            booking.LoadUnfilledWorkorders(1);

            var b = File.ReadAllLines(workFile);

            b.Should().BeEquivalentTo(new string[] {
                "Id,DueDate,Priority,Part,Quantity",
                "12345," + DateTime.Today.AddDays(10).ToString("yyyy-MM-dd") + ",100,part1,50",
                "98765," + DateTime.Today.AddDays(12).ToString("yyyy-MM-dd") + ",100,part2,77"
            });
        }
Ejemplo n.º 2
0
        public void FillWorkorder()
        {
            var workDB = new BlackMaple.CSVOrders.WorkorderCSV();

            workDB.MarkWorkorderAsFilled("work1", new DateTime(2016, 11, 05, 3, 44, 52, DateTimeKind.Utc),
                                         new WorkorderResources
            {
                Serials = new List <string> {
                    "serial1", "serial2"
                },
                Parts = new List <WorkorderPartResources>
                {
                    new WorkorderPartResources
                    {
                        Part                = "part1",
                        PartsCompleted      = 44,
                        ActiveOperationTime = new Dictionary <string, TimeSpan>
                        {
                            { "stat1", TimeSpan.FromMinutes(105) },
                            { "stat2", TimeSpan.FromMinutes(107) }
                        },
                        ElapsedOperationTime = new Dictionary <string, TimeSpan>
                        {
                            { "stat1", TimeSpan.FromMinutes(201) },
                            { "stat2", TimeSpan.FromMinutes(210) },
                            { "stat3", TimeSpan.FromMinutes(222) }
                        }
                    },
                    new WorkorderPartResources
                    {
                        Part                = "part2",
                        PartsCompleted      = 55,
                        ActiveOperationTime = new Dictionary <string, TimeSpan>
                        {
                            { "stat1", TimeSpan.FromMinutes(301) },
                            { "stat2", TimeSpan.FromMinutes(311) },
                            { "stat3", TimeSpan.FromMinutes(333) }
                        },
                        ElapsedOperationTime = new Dictionary <string, TimeSpan>
                        {
                            { "stat1", TimeSpan.FromMinutes(422) },
                            { "stat2", TimeSpan.FromMinutes(462) }
                        }
                    }
                }
            });

            workDB.LoadUnfilledWorkorders(50)
            .ShouldAllBeEquivalentTo(initialWorkorders.GetRange(1, 2));
            workDB.LoadUnfilledWorkorders("part3")
            .ShouldAllBeEquivalentTo(new Workorder[] { initialWorkorders[2] });

            var lines = File.ReadAllLines("filled-workorders/work1.csv");

            Assert.Equal(3, lines.Count());
            Assert.Equal("CompletedTimeUTC,ID,Part,Quantity,Serials,Active stat1 (minutes),Active stat2 (minutes),Active stat3 (minutes),Elapsed stat1 (minutes),Elapsed stat2 (minutes),Elapsed stat3 (minutes)", lines[0]);
            Assert.Equal("2016-11-05T03:44:52Z,work1,part1,44,serial1;serial2,105,107,0,201,210,222", lines[1]);
            Assert.Equal("2016-11-05T03:44:52Z,work1,part2,55,serial1;serial2,301,311,333,422,462,0", lines[2]);
        }
Ejemplo n.º 3
0
        public void LoadUnfilled()
        {
            var workDB = new BlackMaple.CSVOrders.WorkorderCSV();

            workDB.LoadUnfilledWorkorders(30)
            .Should().BeEquivalentTo(initialWorkorders);
            workDB.LoadUnfilledWorkorders(10)
            .Should().BeEquivalentTo(new[] { initialWorkorders[0] });
            workDB.LoadUnfilledWorkorders(null)
            .Should().BeEquivalentTo(initialWorkorders);
        }