예제 #1
0
파일: Helper.cs 프로젝트: cheriephi/diary
        /// <summary>
        /// Tests all PeriodicAppointment fields match the expected values.
        /// </summary>
        internal static void AssertAreEqual(PeriodicAppointmentBuilder expected, PeriodicAppointment actual, string message)
        {
            var messagePrefix = String.Format("{0} Label:<{1}>.", message, expected.GetLabel());

            Assert.AreEqual(expected.GetDetails(), actual.GetDetails(), String.Concat(messagePrefix, " details"));
            Assert.AreEqual(expected.GetDurationMinutes(), actual.GetDurationMinutes(), String.Concat(messagePrefix, " durationMinutes"));
            Assert.AreEqual(true, actual.IsRepeating(), String.Concat(messagePrefix, " IsRepeating"));
            Assert.AreEqual(expected.GetLabel(), actual.GetLabel(), String.Concat(messagePrefix, " label"));

            Assert.AreEqual(ToString(expected.GetOccurs()), ToString(actual.GetStartTime()), String.Concat(messagePrefix, " startTime"));
            Assert.AreNotSame(actual.GetStartTime(), actual.GetStartTime(), String.Concat(messagePrefix, " startTime deep copy"));

            var expectedClassId = new ClassId("PeriodicAppointment");

            Assert.AreEqual(0, actual.GetClassId().CompareTo(expectedClassId), String.Concat(messagePrefix, " classId"));

            //Test Contact relations
            var relation        = actual.GetContacts();
            var contactBuilders = expected.GetContactBuilders();

            Assert.AreEqual(contactBuilders.Length, relation.GetChildCount(), String.Concat(messagePrefix, " contacts.Count"));

            for (int i = 0; i < contactBuilders.Length; i++)
            {
                Helper.AssertAreEqual(contactBuilders[i], relation.GetChild(i), String.Concat(messagePrefix, " contacts[", i.ToString(), "].Data"));
            }
        }
예제 #2
0
        public void GetContactsTest()
        {
            var builder = new PeriodicAppointmentBuilder();

            var appointment = (PeriodicAppointment)builder.SetContactBuilders().Build();

            var contactBuilders = builder.GetContactBuilders();

            foreach (var contactBuilder in contactBuilders)
            {
                appointment.AddRelation((Contact)contactBuilder.Build());
            }

            Helper.AssertAreEqual(builder, appointment, "");
        }