Esempio n. 1
0
        public void ToStringTestParagraph(int id, int actionId, int noteId, string name, string text, string[] points, bool[] isCheckeds)
        {
            Random   random      = new Random();
            DateTime created     = DateTime.Now.AddDays(random.NextDouble() * -1);
            DateTime lastChanged = DateTime.Now;
            DateTime startT      = new DateTime(random.Next());
            DateTime endT        = new DateTime(random.Next());

            if (startT > endT)
            {
                DateTime t = startT;
                startT = endT;
                endT   = t;
            }

            DBContext.Missions.Clear();
            DBContext.Actions.Clear();
            DBContext.Notes.Clear();
            DBContext.Users.Clear();
            DBContext.Points.Clear();
            DBContext.Collections.Clear();

            User user = new User("Name", "Login", "Password", DateTime.Now);

            DBContext.Users.Add(user);

            Note note = new Note(noteId, user, new Collection(), name, text, created, lastChanged);

            DBContext.Notes.Add(note);

            Database.Context.Action action = new Database.Context.Action(actionId, note, startT, endT);
            DBContext.Actions.Add(action);

            Collection paragraph = new Collection(points.Length);

            DBContext.Collections.Add(paragraph);

            for (int i = 0; i < points.Length; ++i)
            {
                Point point = new Point(paragraph, points[i], isCheckeds[i]);
                DBContext.Points.Add(point);
            }

            Mission mission = new Mission(id, action, false, paragraph);

            DBContext.Missions.Add(mission);

            Assert.AreEqual("\b<sm>\b" + (id * -1).ToString() + "\b<sm>\b" + action.ToString() + "\b<sm>\b" + paragraph.ToString() + "\b<sm>\b", mission.ToString());
        }
Esempio n. 2
0
        public void ToStringTestProgress(int id, int actionId, int noteId, string name, string text, int start, int current, int end)
        {
            Random   random      = new Random();
            DateTime created     = DateTime.Now.AddDays(random.NextDouble() * -1);
            DateTime lastChanged = DateTime.Now;
            DateTime startT      = new DateTime(random.Next());
            DateTime endT        = new DateTime(random.Next());

            if (startT > endT)
            {
                DateTime t = startT;
                startT = endT;
                endT   = t;
            }

            DBContext.Missions.Clear();
            DBContext.Actions.Clear();
            DBContext.Notes.Clear();
            DBContext.Users.Clear();
            DBContext.Progresses.Clear();

            User user = new User("Name", "Login", "Password", DateTime.Now);

            DBContext.Users.Add(user);

            Note note = new Note(noteId, user, new Collection(), name, text, created, lastChanged);

            DBContext.Notes.Add(note);

            Database.Context.Action action = new Database.Context.Action(actionId, note, startT, endT);
            DBContext.Actions.Add(action);

            Progress progress = new Progress(start, current, end);

            DBContext.Progresses.Add(progress);

            Mission mission = new Mission(id, action, true, progress);

            DBContext.Missions.Add(mission);

            Assert.AreEqual("\b<sm>\b" + id.ToString() + "\b<sm>\b" + action.ToString() + "\b<sm>\b" + progress.ToString() + "\b<sm>\b", mission.ToString());
        }
Esempio n. 3
0
        public void ToStringTest(int id, int noteId, string name, string text)
        {
            User user = new User("Name", "Login", "Password", DateTime.Now);

            DBContext.Users.Add(user);

            Random   random      = new Random();
            DateTime created     = DateTime.Now.AddDays(random.NextDouble() * -1);
            DateTime lastChanged = DateTime.Now;
            Note     note        = new Note(noteId, user, new Collection(), name, text, created, lastChanged);

            DBContext.Notes.Add(note);

            DateTime start = new DateTime(random.Next());
            DateTime end   = new DateTime(random.Next());

            if (start > end)
            {
                DateTime t = start;
                start = end;
                end   = t;
            }
            Database.Context.Action action = new Database.Context.Action(id, note, start, end);

            Assert.AreEqual("\b<sa>\b" + id.ToString() + "\b<sa>\b" + note.ToString() + "\b<sa>\b" + (start - DateTime.MinValue).TotalDays.ToString() + "\b<sa>\b" + (end - DateTime.MinValue).TotalDays.ToString() + "\b<sa>\b", action.ToString());
        }