public StubContactSummary Clone() { var clone = new StubContactSummary { IsDeleted = this.IsDeleted, Provider = this.Provider, AccountId = this.AccountId, ProviderId = this.ProviderId, Title = this.Title, DateOfBirth = this.DateOfBirth, FullName = this.FullName, }; clone.AvatarUris.AddRange(this.AvatarUris); clone.Tags.AddRange(this.Tags); clone.Handles.AddRange(this.Handles); clone.Organizations.AddRange(this.Organizations); clone.Relationships.AddRange(this.Relationships); return clone; }
public void UpdatingContactAggregateWithMatchingContact() { var initialContact = new StubContactSummary { Provider = "StubProvider", AccountId = "*****@*****.**", ProviderId = "*****@*****.**", Title = "Jonny Doe", Handles = { new ContactEmailAddress("*****@*****.**", "home"), } }; var matchingContact = new StubContactSummary { Provider = "StubProvider", AccountId = "*****@*****.**", ProviderId = "*****@*****.**", Handles = { new ContactEmailAddress("*****@*****.**", "other"), new ContactPhoneNumber("+44 7 1234 56778", "mobile"), } }; var expected = new ContactAggregateUpdate { Version = 2, NewTitle = initialContact.Title, AddedProviders = new[] { new ContactProviderSummary(initialContact.Provider, initialContact.AccountId, initialContact.ProviderId), new ContactProviderSummary(matchingContact.Provider, matchingContact.AccountId, matchingContact.ProviderId), }, AddedHandles = initialContact.Handles .Concat(matchingContact.Handles.Skip(1)) .Select(h => new ContactHandleRecord(h)) .ToArray() }; new UserContactUpdateSingleContactAggregateScenario() .Given(s => s.Given_a_UserContacts_instance()) .When(s => s.When_a_ContactSummary_is_added(initialContact)) .When(s => s.When_a_ContactSummary_is_added(matchingContact)) .Then(s => s.Then_Snapshot_has_only(expected)) .BDDfy(); }
private static StubContactSummary GenerateContact(string accountId, string title, string providerId, string email = null) { var contact = new StubContactSummary { Provider = "StubProvider", AccountId = accountId, Title = title, ProviderId = providerId }; if (email != null) contact.Handles.Add(new ContactEmailAddress(email, "Home")); return contact; }
public void Merging_multiple_contacts() { var accId = "ABC"; var barx = new StubContactSummary { Provider = "Google", AccountId = accId, Title = "Campbell, Erynne", ProviderId = "http://www.google.com/m8/feeds/contacts/lee.ryan.campbell%40gmail.com/base/37cc52308c94e30f", Handles = { new ContactEmailAddress("*****@*****.**", "work"), new ContactEmailAddress("*****@*****.**", "work"), } }; var old = new StubContactSummary { Provider = "Google", AccountId = accId, Title = "Erynne Campbell", ProviderId = "http://www.google.com/m8/feeds/contacts/lee.ryan.campbell%40gmail.com/base/aa", Handles = { new ContactEmailAddress("*****@*****.**", "Obsolete"), new ContactPhoneNumber("+61417910632", "mobile"), new ContactPhoneNumber("+447554257819", "mobile"), } }; var current = new StubContactSummary { Provider = "Google", AccountId = accId, Title = "Erynne Campbell", ProviderId = "http://www.google.com/m8/feeds/contacts/lee.ryan.campbell%40gmail.com/base/78a2b08a3e7700", Handles = { new ContactEmailAddress("*****@*****.**", "Obsolete"), } }; var expected = new ContactAggregateUpdate() { //Id = ?? Version = 3, NewTitle = "Erynne Campbell", IsDeleted = false, AddedProviders = new ContactProviderSummary[] { new ContactProviderSummary{ AccountId = accId, ContactId = "http://www.google.com/m8/feeds/contacts/lee.ryan.campbell%40gmail.com/base/37cc52308c94e30f", ProviderName = "Google" }, new ContactProviderSummary{ AccountId = accId, ContactId = "http://www.google.com/m8/feeds/contacts/lee.ryan.campbell%40gmail.com/base/aa", ProviderName = "Google" }, new ContactProviderSummary{ AccountId = accId, ContactId = "http://www.google.com/m8/feeds/contacts/lee.ryan.campbell%40gmail.com/base/78a2b08a3e7700", ProviderName = "Google" } }, AddedHandles = new ContactHandle[] { new ContactEmailAddress("*****@*****.**", "work"), new ContactEmailAddress("*****@*****.**", "work"), new ContactEmailAddress("*****@*****.**", "Obsolete"), new ContactPhoneNumber("+61417910632", "mobile"), new ContactPhoneNumber("+447554257819", "mobile"), new ContactEmailAddress("*****@*****.**", "Obsolete"), }.Select(h => new ContactHandleRecord(h)) .ToArray() }; new UserContactUpdateSingleContactAggregateScenario() .Given(s => s.Given_a_UserContacts_instance()) .When(s => s.When_a_ContactSummary_is_added(barx)) .When(s => s.When_a_ContactSummary_is_added(old)) .When(s => s.When_a_ContactSummary_is_added(current)) .Then(s => s.Then_Snapshot_has_only(expected)) .BDDfy(); }