public void CreateTest()
        {
            var item = _items.Create(new TrackItem
            {
                Item = "SMPL-001",
                Time = 0.5f,
                Date = DateTime.Now
            });

            Assert.IsNotNull(item.Id);
            Assert.AreEqual(DateTime.Now.ToString("yyyy-MM-dd"), item.Date.ToString("yyyy-MM-dd"));
            Assert.AreEqual("SMPL-001", item.Item);
            Assert.AreEqual(0.5f, item.Time);
            Assert.IsNull(item.Url);
        }
示例#2
0
 public int Create(TrackItem target)
 {
     using (var items = new TrackItemService())
     {
         try
         {
             var created = items.Create(target);
             Console.ForegroundColor = ConsoleColor.Green;
             Console.WriteLine($"Saved [{created.Id} - {created.Item}] Successfully \n{created}");
             Console.ResetColor();
         }
         catch (Exception e)
         {
             Console.ForegroundColor = ConsoleColor.Red;
             Console.WriteLine($"Failed to Create {target.Item}. {e.Message}");
             Console.ResetColor();
             return((int)ExitCodes.FailedToCreateItem);
         }
         return((int)ExitCodes.Success);
     }
 }
示例#3
0
 protected int CreateDatabase(string path)
 {
     try
     {
         TrackItem itemCreated;
         Period    periodCreated;
         using (var items = new TrackItemService())
         {
             itemCreated = items.Create(new TrackItem
             {
                 Item = "SMPL-001",
                 Time = 0.5f,
                 Date = DateTime.Now
             });
         }
         using (var periods = new PeriodService())
         {
             periodCreated = periods.Create(new Period
             {
                 Name      = "Sample Period",
                 EzName    = "sample",
                 StartDate = DateTime.Now,
                 EndDate   = DateTime.Now.AddDays(1),
                 Items     = new TrackItem[] { itemCreated }
             });
         }
         Console.WriteLine($"Succesfully Created Item and Period Databases \"{Path.Combine(path, "trackmat.db")}\"");
         Console.WriteLine(itemCreated);
         Console.WriteLine(periodCreated);
         Console.ResetColor();
     }
     catch (Exception e)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine($"Failed to create config database at {path}. {e.Message}");
         return((int)ExitCodes.FailedInitAtDatabase);
     }
     return((int)ExitCodes.Success);
 }