public void FillDataFrom(Profile profile) { if (!string.IsNullOrWhiteSpace(profile.Email)) Email = profile.Email; if (!string.IsNullOrWhiteSpace(profile.Name)) Name = profile.Name; if (!string.IsNullOrWhiteSpace(profile.Organization)) Organization = profile.Organization; if (!string.IsNullOrWhiteSpace(profile.Title)) Title = profile.Title; if (!string.IsNullOrWhiteSpace(profile.Country)) Country = profile.Country; }
public bool Equals(Profile otherProfile) { return otherProfile != null && Email == otherProfile.Email && Name == otherProfile.Name && Organization == otherProfile.Organization && Title == otherProfile.Title && Country == otherProfile.Country; }
public void Constructor_GivenEmptyXml_ShouldHaveEmptyProperties() { var xml = XDocument.Parse("<CHAOS.Profile></CHAOS.Profile>"); var profile = new Profile(xml); Assert.IsEmpty(profile.Email); Assert.IsEmpty(profile.Name); Assert.IsEmpty(profile.Organization); Assert.IsEmpty(profile.Title); Assert.IsEmpty(profile.Country); }
public void Constructor_GivenSeperateValues_ShouldPopulateProperties() { const string email = "*****@*****.**"; const string name = "Peter"; const string organization = "Institut"; const string title = "Walker"; const string country = "Denmark"; var profile = new Profile(email, name, organization, title, country); Assert.AreEqual(email, profile.Email); Assert.AreEqual(name, profile.Name); Assert.AreEqual(organization, profile.Organization); Assert.AreEqual(title, profile.Title); Assert.AreEqual(country, profile.Country); }
public void Constructor_ShouldParseOutFromToXml() { const string email = "*****@*****.**"; const string name = "Peter"; const string organization = "Institut"; const string title = "Walker"; const string country = "Denmark"; var profile1 = new Profile(email, name, organization, title, country); var profile2 = new Profile(profile1.ToXml()); Assert.AreEqual(email, profile2.Email); Assert.AreEqual(name, profile2.Name); Assert.AreEqual(organization, profile2.Organization); Assert.AreEqual(title, profile2.Title); Assert.AreEqual(country, profile2.Country); }
public void Constructor_GivenXml_ShouldPopulateProperties() { const string email = "*****@*****.**"; const string name = "Peter"; const string organization = "Institut"; const string title = "Walker"; const string country = "Denmark"; var xml = XDocument.Parse("<CHAOS.Profile><Name>Peter</Name><Title>Walker</Title><About></About><Organization>Institut</Organization><Emails><Email>[email protected]</Email></Emails><Phonenumbers><Phonenumber></Phonenumber></Phonenumbers><Websites><Website></Website></Websites><Skype></Skype><LinkedIn></LinkedIn><Twitter></Twitter><Address></Address><City></City><ZipCode></ZipCode><Country>Denmark</Country></CHAOS.Profile>"); var profile = new Profile(xml); Assert.AreEqual(email, profile.Email); Assert.AreEqual(name, profile.Name); Assert.AreEqual(organization, profile.Organization); Assert.AreEqual(title, profile.Title); Assert.AreEqual(country, profile.Country); }
public void Equals_GivenEqualProfiles_ShouldReturnTrue() { const string email = "*****@*****.**"; const string name = "Peter"; const string organization = "Institut"; const string title = "Walker"; const string country = "Denmark"; var profile1 = new Profile(email, name, organization, title, country); var profile2 = new Profile(email, name, organization, title, country); Assert.IsTrue(profile1.Equals(profile2)); Assert.IsTrue(profile1.Equals(profile1)); }
public void FillDataFrom_HasEmptyEmail_ShouldNotFillInEmail() { const string existingEmail = "*****@*****.**"; const string existingName = "Hans"; const string existingOrganization = "Institut"; const string existingTitle = "Walker"; const string existingCountry = "Denmark"; const string email = ""; const string name = "Peter"; const string organization = "Skolen"; const string title = "Runner"; const string country = "Sverige"; var existingProfile = new Profile(existingEmail, existingName, existingOrganization, existingTitle, existingCountry); var fillingProfile = new Profile(email, name, organization, title, country); existingProfile.FillDataFrom(fillingProfile); Assert.AreEqual(existingEmail, existingProfile.Email); Assert.AreEqual(name, existingProfile.Name); Assert.AreEqual(organization, existingProfile.Organization); Assert.AreEqual(title, existingProfile.Title); Assert.AreEqual(country, existingProfile.Country); }
public void FillDataFrom_PartiallyEmptyProfileGivenFullProfile_ShouldOverwriteEmptyProperties() { const string existingEmail = "*****@*****.**"; const string existingName = "Hans"; const string existingOrganization = "Institut"; const string existingTitle = "Walker"; const string existingCountry = "Denmark"; const string email = "*****@*****.**"; const string title = "Weep"; var existingProfile = new Profile(existingEmail, existingName, existingOrganization, existingTitle, existingCountry); var fillingProfile = new Profile(email, null, "", title, " "); existingProfile.FillDataFrom(fillingProfile); Assert.AreEqual(email, existingProfile.Email); Assert.AreEqual(existingName, existingProfile.Name); Assert.AreEqual(existingOrganization, existingProfile.Organization); Assert.AreEqual(title, existingProfile.Title); Assert.AreEqual(existingCountry, existingProfile.Country); }
public void FillDataFrom_EmptyProfileGivenFullProfile_ShouldOverwriteEverything() { const string email = "*****@*****.**"; const string name = "Peter"; const string organization = "Institut"; const string title = "Walker"; const string country = "Denmark"; var existingProfile = new Profile("", "", null, null, null); var fillingProfile = new Profile(email, name, organization, title, country); existingProfile.FillDataFrom(fillingProfile); Assert.AreEqual(email, existingProfile.Email); Assert.AreEqual(name, existingProfile.Name); Assert.AreEqual(organization, existingProfile.Organization); Assert.AreEqual(title, existingProfile.Title); Assert.AreEqual(country, existingProfile.Country); }
public void ToXmlString_ShouldCorrectXml() { const string email = "*****@*****.**"; const string name = "Peter"; const string organization = "Institut"; const string title = "Walker"; const string country = "Denmark"; var profile = new Profile(email, name, organization, title, country); var xmlString = profile.ToXmlString(); Assert.That(xmlString, Is.EqualTo("<CHAOS.Profile><Name>Peter</Name><Title>Walker</Title><About></About><Organization>Institut</Organization><Emails><Email>[email protected]</Email></Emails><Phonenumbers><Phonenumber></Phonenumber></Phonenumbers><Websites><Website></Website></Websites><Skype></Skype><LinkedIn></LinkedIn><Twitter></Twitter><Address></Address><City></City><ZipCode></ZipCode><Country>Denmark</Country></CHAOS.Profile>")); }