public void EqualsTest(int id1, int id2, int id3, int id4, int id5, string name, string text, int id1_2, int id2_2, int id3_2, int id4_2, int id5_2, string name_2, string text_2, bool expectedResult) { DateTime t = DateTime.Now; ProgressMission mission1 = new ProgressMission(id1, id2, id3, id4, id5, name, text, t, t, t, t); ProgressMission mission2 = new ProgressMission(id1_2, id2_2, id3_2, id4_2, id5_2, name_2, text_2, t, t, t, t); Assert.AreEqual(expectedResult, mission1.Equals(mission2)); }
public void InitializationTestProgress(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; } ServerRealization.Database.Context.User dbUser = new ServerRealization.Database.Context.User("Name", "Login", "Password", DateTime.Now); ServerRealization.Database.Context.Note dbNote = new ServerRealization.Database.Context.Note(noteId, dbUser, new ServerRealization.Database.Context.Collection(), name, text, created, lastChanged); ServerRealization.Database.Context.Action dbAction = new ServerRealization.Database.Context.Action(actionId, dbNote, startT, endT); ServerRealization.Database.Context.Mission dbMission = new ServerRealization.Database.Context.Mission(id, dbAction, true, new ServerRealization.Database.Context.Progress(start, current, end)); ProgressMission mission = (ProgressMission)Mission.CreateNew(dbMission.ToString()); Assert.AreEqual(id, mission.Id); Assert.AreEqual(actionId, mission.ActionId); Assert.AreEqual(noteId, mission.NoteId); Assert.AreEqual(name, mission.Name); Assert.AreEqual(text, mission.Text); Assert.AreEqual(start, ((Progress)mission.Context).Start); Assert.AreEqual(current, mission.Context.Count); Assert.AreEqual(end, ((Progress)mission.Context).End); if (created > mission.Created) { Assert.IsTrue((created - mission.Created).TotalSeconds < 1); } else if (mission.Created > created) { Assert.IsTrue((mission.Created - created).TotalSeconds < 1); } if (lastChanged > mission.LastChanged) { Assert.IsTrue((lastChanged - mission.LastChanged).TotalSeconds < 1); } else if (mission.LastChanged > lastChanged) { Assert.IsTrue((mission.LastChanged - lastChanged).TotalSeconds < 1); } if (startT > mission.Start) { Assert.IsTrue((startT - mission.Start).TotalSeconds < 1); } else if (mission.Start > startT) { Assert.IsTrue((mission.Start - startT).TotalSeconds < 1); } if (endT > mission.End) { Assert.IsTrue((endT - mission.End).TotalSeconds < 1); } else if (mission.End > endT) { Assert.IsTrue((mission.End - endT).TotalSeconds < 1); } }