public void CanMarkAContactAsAContractor() { CrudProxy proxy = new ContactProxy(); ContactDto contact = GetContact1(); proxy.Insert(contact); var fromDb = (ContactDto)proxy.GetByUid(contact.Uid); Assert.IsFalse(((ContactType)fromDb.ContactType).HasFlag(ContactType.Contractor), "Shouldn't be flagged a contactor."); var contactTypeFlag = ContactType.Contractor | ContactType.Supplier; contact.ContactType = (int)contactTypeFlag; proxy.Update(contact); fromDb = (ContactDto)proxy.GetByUid(contact.Uid); Assert.AreEqual((int)contactTypeFlag, fromDb.ContactType, "Incorrect contact type."); var contactType = (ContactType)fromDb.ContactType; Assert.IsTrue(contactType.HasFlag(ContactType.Contractor), "IsContractor should be true."); Assert.IsTrue(contactType.HasFlag(ContactType.Supplier), "IsSupplier should be true."); Assert.IsFalse(contactType.HasFlag(ContactType.Customer), "IsCustomer should be false."); }
public void UpdateContactOrganizationDetails() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); int tempContactUid = dto1.Uid; string lastUpdatedUid = dto1.LastUpdatedUid; dto1 = this.GetContact2(); dto1.OrganisationName = "Updated Organization Name"; dto1.OrganisationAbn = "U1234567"; dto1.OrganisationPosition = "Updated Organization Position"; dto1.OrganisationWebsite = "www.updatedorg.com"; dto1.Uid = tempContactUid; dto1.LastUpdatedUid = lastUpdatedUid; proxy.Update(dto1); var tmpDto = (ContactDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, tmpDto); }
public void InsertContactWithBankDetails() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact3(); proxy.Insert(dto1); AssertEqual(dto1, (ContactDto)proxy.GetByUid(dto1.Uid)); }
protected void SetupContacts() { CrudProxy contact = new ContactProxy(); this.MrSmith = new ContactDto(); this.MrSmith.Salutation = Salutation.Mr; this.MrSmith.GivenName = "John"; this.MrSmith.FamilyName = "Smith"; this.MrSmith.OrganisationName = "ACME Pty Ltd"; contact.Insert(this.MrSmith); this.MrsSmith = new ContactDto(); this.MrsSmith.Salutation = Salutation.Mrs; this.MrsSmith.GivenName = "Mary"; this.MrsSmith.FamilyName = "Smith"; this.MrsSmith.OrganisationName = "ACME Pty Ltd"; contact.Insert(this.MrsSmith); }
public void InsertUsingUnsupportedSalutation() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); dto1.Salutation = "Sir"; // Should be ok, but won't be shown on UI. proxy.Insert(dto1); }
public void InvalidABN() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContactInvalidAbn(); proxy.Insert(dto1); ContactDto fromDB = (ContactDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual("ABC123", fromDB.OrganisationAbn, "Incorrect org. abn."); }
public void InsertWithDefaultSaleDiscount() { CrudProxy proxy = new ContactProxy(); ContactDto contact = GetContact1(); contact.DefaultSaleDiscount = 10.50M; proxy.Insert(contact); ContactDto fromDb = (ContactDto)proxy.GetByUid(contact.Uid); AssertEqual(contact, fromDb); }
public void CanInsertAContractor() { CrudProxy proxy = new ContactProxy(); ContactDto contact = GetContact1(); contact.ContactType = (int)ContactType.Contractor; proxy.Insert(contact); var fromDb = (ContactDto)proxy.GetByUid(contact.Uid); AssertEqual(contact, fromDb); Assert.IsTrue(((ContactType)fromDb.ContactType).HasFlag(ContactType.Contractor), "Contractor flag should be set."); }
public void InsertWithTags() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact4(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); ContactDto dto2 = (ContactDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2, true); }
private void AddCarl() { CrudProxy proxy = new ContactProxy(); ContactDto dto = new ContactDto(); dto.Salutation = "Mr."; dto.GivenName = "Carl"; dto.FamilyName = "O'Neil"; dto.OrganisationName = "O'Neil Capital"; dto.ContactID = "GLD879"; dto.CustomField1 = "O'Neil"; proxy.Insert(dto); Assert.IsTrue(dto.Uid > 0, "Incorrect uid post save."); }
public void InsertWithCustomField() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); dto1.CustomField1 = "This is custom field 1"; dto1.CustomField2 = "This is custom field 2"; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after insert."); dto1 = (ContactDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual("This is custom field 1", dto1.CustomField1, "Incorrect custom field 1"); Assert.AreEqual("This is custom field 2", dto1.CustomField2, "Incorrect custom field 2"); }
public void UpdateWithDefaultPurchaseDiscount() { CrudProxy proxy = new ContactProxy(); ContactDto contact = GetContact1(); contact.DefaultPurchaseDiscount = 15.75M; proxy.Insert(contact); contact.DefaultPurchaseDiscount = 14.75M; proxy.Update(contact); ContactDto fromDb = (ContactDto)proxy.GetByUid(contact.Uid); AssertEqual(contact, fromDb); }
public void InsertWithTwitterIdAndSkypeID() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); dto1.TwitterId = "Contact1TwitterId"; dto1.SkypeId = "Contact1SkypeId"; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after insert."); dto1 = (ContactDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual("Contact1TwitterId", dto1.TwitterId, "Incorrect twitter ID"); Assert.AreEqual("Contact1SkypeId", dto1.SkypeId, "Incorrect skype ID"); }
public void InsertWithCustomFieldLongerThan50Chars() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); dto1.CustomField1 = "This is custom field 1 This is custom field 1 This is custom field 1 This is custom field 1 This is custom field 1 This is custom field 1 This is custom field 1"; try { proxy.Insert(dto1); throw new Exception("The expected exception is not thrown."); } catch (RestException rex) { Assert.AreEqual("The custom field 1 must not exceed 50 characters.", rex.Message, "Incorrect exception message."); } }
public void UpdateWithLinkedInPublicProfile() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); dto1.LinkedInPublicProfile = "http://www.linkedin.com/pub/kasun-amarasinghe/5/984/b5b"; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after insert."); dto1.LinkedInPublicProfile = "http://www.linkedin.com/in/marclehmann"; proxy.Update(dto1); dto1 = (ContactDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual("http://www.linkedin.com/in/marclehmann", dto1.LinkedInPublicProfile, "Incorrect LinkedIn Public Profile"); }
public void TradingTermsBackwardsCompatibility() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); dto1.SaleTradingTermsPaymentDueInInterval = 14; dto1.SaleTradingTermsPaymentDueInIntervalType = 1; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after insert."); dto1 = (ContactDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(1, dto1.SaleTradingTerms.Type, "Incorrect Sale Trading Terms Type"); Assert.AreEqual(14, dto1.SaleTradingTerms.Interval, "Incorrect Sale Trading Terms Interval"); Assert.AreEqual(1, dto1.SaleTradingTerms.IntervalType, "Incorrect Sale Trading Terms Interval Type"); }
public void EnsureInvalidControlCharactersAreRemoved() { CrudProxy proxy = new ContactProxy(); ContactDto validContact = GetContact1(); ContactDto invalidContact = GetContact1(); invalidContact.GivenName = invalidContact.GivenName + "\r\n"; invalidContact.FamilyName = invalidContact.FamilyName + "\r\n"; invalidContact.OrganisationName = invalidContact.OrganisationName + " "; proxy.Insert(invalidContact); var fromDb = (ContactDto)proxy.GetByUid(invalidContact.Uid); Assert.AreEqual(validContact.GivenName, fromDb.GivenName, "Given name should not contain any invalid characters."); Assert.AreEqual(validContact.FamilyName, fromDb.FamilyName, "Family name should not contain any invalid characters"); Assert.AreEqual(validContact.OrganisationName, fromDb.OrganisationName, "Organisation name should not contain any invalid characters."); }
public void Update() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); int tempContactUid = dto1.Uid; string lastUpdatedUid = dto1.LastUpdatedUid; dto1 = this.GetContact2(); dto1.Uid = tempContactUid; dto1.LastUpdatedUid = lastUpdatedUid; proxy.Update(dto1); AssertEqual(dto1, (ContactDto)proxy.GetByUid(dto1.Uid)); }
public void Delete() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); proxy.Insert(dto1); proxy.DeleteByUid(dto1.Uid); try { proxy.GetByUid(dto1.Uid); throw new Exception("The expected exception was not thrown."); } catch (RestException ex) { Assert.AreEqual("RecordNotFoundException", ex.Type, "Incorrect exception type."); } }
public void PurchaseTradingTerms() { CrudProxy proxy = new ContactProxy(); ContactDto dto1 = this.GetContact1(); dto1.SaleTradingTermsPaymentDueInInterval = 0; dto1.SaleTradingTermsPaymentDueInIntervalType = 0; dto1.PurchaseTradingTermsPaymentDueInInterval = 0; dto1.PurchaseTradingTermsPaymentDueInIntervalType = 0; dto1.SaleTradingTerms = GetPurchaseTradingTermsDto1(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after insert."); dto1 = (ContactDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(2, dto1.SaleTradingTerms.Type, "Incorrect Purchase Trading Terms Type"); Assert.AreEqual(30, dto1.SaleTradingTerms.Interval, "Incorrect Purchase Trading Terms Interval"); Assert.AreEqual(1, dto1.SaleTradingTerms.IntervalType, "Incorrect Purchase Trading Terms Interval Type"); }