示例#1
0
        public void LocalCrmTests_NonPrimitiveDataTypesAreCloned()
        {
            var service = GetService();
            var contact = new Contact();

            contact.Id = service.Create(contact);
            var phoneCall = new PhoneCall();

            phoneCall.Id = service.Create(phoneCall);

            SetActivityParty(phoneCall, PhoneCall.Fields.From, new ActivityParty {
                PartyId = contact.ToEntityReference()
            });
            phoneCall.CreatedBy = contact.ToEntityReference();

            service.Update(phoneCall);

            phoneCall.CreatedBy.Name = "Test";
            Assert.AreEqual(1, service.GetFirst <PhoneCall>().From.Count());

            var from = phoneCall.GetAttributeValue <EntityCollection>(PhoneCall.Fields.From);

            from.Entities.Clear();

            Assert.IsNull(service.GetFirst <PhoneCall>().CreatedBy.Name);
            Assert.AreEqual(1, service.GetFirst <PhoneCall>().From.Count());
        }