public void MarriedPersonHasFamily() { Person p1 = new Person() { Gender = "M" }; Person p2 = new Person() { Gender = "F" }; p1.Marry(p2); Assert.NotNull(p1.Family); Assert.NotNull(p2.Family); Assert.Same(p1.Family, p2.Family); }
public void FamilyHasHusbandAndWife() { Person p1 = new Person() { Gender = "M" }; Person p2 = new Person() { Gender = "F" }; Family f = p1.Marry(p2); Assert.Same(f.Husband, p1); Assert.Same(f.Wife, p2); }
public void ThrowsExceptionIfAgeLessThan20Years() { Person p1 = new Person(); Person p2 = new Person(); int thisYear = DateTime.Now.Year; p1.BirthYear = thisYear - 15; // 15 yo. p2.BirthYear = thisYear - 30; // 30 yo. //Assert.Throws(typeof(Exception), () => { // p1.Marry(p2); //}); Assert.Throws<Exception>(() => { p1.Marry(p2); }); }
public void ShouldReturnFamily() { Person p1 = new Person(); Person p2 = new Person(); p1.Gender = "M"; p2.Gender = "F"; Family f = p1.Marry(p2); Assert.NotNull(f); }
public void MaleCannotMarryToMale() { Person p1 = new Person(); Person p2 = new Person(); p1.Gender = "M"; p2.Gender = "M"; Assert.Throws<Exception>(() => { p1.Marry(p2); }); }
public void MaleCanMarryToFemale() { Person p1 = new Person(); Person p2 = new Person(); p1.Gender = "M"; p2.Gender = "F"; Assert.DoesNotThrow(() => { p1.Marry(p2); }); }
public void ThrowExceptionIfAgeLessThan20Years() { Person p1 = new Person(); Person p2 = new Person(); int thisYear = DateTime.Now.Year; p1.BirthYear = thisYear; //0 p2.BirthYear = thisYear; //0 // Generics Assert.Throws<Exception>(() => { p1.Marry(p2); }); }
public void MaleCanMarryToFemaleIfAgeGreaterThan20() { Person p1 = new Person(); Person p2 = new Person(); int thisYear = DateTime.Now.Year; p1.BirthYear = thisYear - 30; //20 p2.BirthYear = thisYear - 30; //20 p1.Gender = "M"; p2.Gender = "F"; Assert.DoesNotThrow(() => { p1.Marry(p2); }); }