public void Init()
 {
     patient = new Patient
     {
         Firstname = "AA",
         Surname = "BB",
         DateOfBirth = DateTime.Today,
         Gender = "M",
         Index = 1
     };
     residentialAddress = new Address
     {
         StreetNumber = "10",
         Line1 = "Hope st",
         Suburb = "ASD Park",
         PostCode = "4000",
         Country = "Australia",
         DefaultAddress = true,
         AddressType = AddressType.Residential
     };
     postalAddress = new Address
     {
         StreetNumber = "20",
         Line1 = "Tom st",
         Suburb = "Norman Park",
         PostCode = "4002",
         Country = "Australia",
         DefaultAddress = false,
         AddressType = AddressType.Postal
     };
     patient.Addresses.Add(residentialAddress);
     patient.Addresses.Add(postalAddress);
 }
 public void ItWillAddAnyAddressWhichMissedThatTypeInRepositoryWhenUpdating()
 {
     var patinetInRepository = new Patient
     {
         Firstname = "AAA",
         Surname = "BBB",
         DateOfBirth = DateTime.Today,
         Gender = "M",
         Index = 1
     };
     var residentialAddressInRepository = new Address
     {
         StreetNumber = "10",
         Suburb = "dfgdf",
         PostCode = "4544",
         Line1 = "Irwe rwer",
         Country = "ewrwe",
         DefaultAddress = true,
         AddressType = AddressType.Residential
     };
     validatorService.Validate(Arg.Is(patient), Arg.Any<Func<Patient, bool>>()).Returns(true);
     patinetInRepository.Addresses.Add(residentialAddressInRepository);
     patientRepository.GetPatientWithAddress(Arg.Any<int>()).Returns(patinetInRepository);
     patientService.UpdatePatient(patient);
     patientRepository.Received().AddOrUpdate(Arg.Any<Patient>());
     unitOfWork.Received().Save();
     patient.Addresses.Any(a => a.AddressType == AddressType.Postal).Should().BeTrue();
 }
 public void ItShouldNotBePossibleToAddTwoAddressWithOneType()
 {
     var newResidentialAddress = new Address
     {
         StreetNumber = "17",
         PostCode = "4646",
         DefaultAddress = false,
         Line1 = "Something",
         Suburb = "ww Park",
         Country = "ter"
     };
     patient.Addresses.Add(newResidentialAddress);
     validatorService.Validate(Arg.Is(patient), Arg.Any<Func<Patient, bool>>()).Returns(true);
     patientService.AddPatient(patient);
     patientRepository.DidNotReceive().AddOrUpdate(Arg.Is(patient));
     unitOfWork.DidNotReceive().Received().Save();
 }