locked
Assert condition failure in unit tests RRS feed

  • Question

  • Hi,

    I am trying to debug this unit test, which sets the priority of the institution and if blank sets it to max priority + increment value.

    The test fails at assert condition. Also, I have noticed that the guid(or id) value is empty, which means it is not creating a record!

    Here's the code:

    public void SetInstitutionalPriorityForOrganization()
            {
               
                decimal maxPriority = 90M;
                int increment;
                if (!Int32.TryParse(UserPrompts.ContituentTypePriorityIncrementValue, out increment))
                    increment = 1;

                ConstituentType constituentType1 = new ConstituentType();
                constituentType1.Type = "Unit Test Org 1";
                constituentType1.Classification = ConstituentType.ClassificationOption.Organization;
                constituentType1.InstitutionalPriority = maxPriority;
                constituentType1.Id = TestUtility.CrmData.Create(constituentType1);
                _records.Add(new TestDataItem(constituentType1.Id, ConstituentType.EntityLogicalName));

               
                ConstituentType constituentType2 = new ConstituentType();
                constituentType2.Type = "Unit Test Org 2";
                constituentType2.Classification = ConstituentType.ClassificationOption.Organization;
                constituentType2.Id = Guid.NewGuid();
                constituentType2.SetInstitutionalPriority(TestUtility.CrmData);

               
                Assert.AreEqual(constituentType2.InstitutionalPriority, (maxPriority + increment));
                
                // Clean Up
                var constituentTypes = _records.Where(x => x.Entity == ConstituentType.EntityLogicalName).ToList();
                foreach (TestDataItem type in constituentTypes)
                {
                    TestUtility.CrmData.Delete(type.Entity, type.Guid);
                }
            }

    Thanks

    Friday, December 26, 2014 2:04 PM