public void GetHomeAddress_NoAlternative_ShouldReturnActualHomeAddress()
        {
            var testPerson = new Person
            {
                Id = 1
            };

            _personalAddressRepoMock.AsQueryable().ReturnsForAnyArgs(new List <PersonalAddress>
            {
                new PersonalAddress
                {
                    Type         = PersonalAddressType.Home,
                    PersonId     = 1,
                    Person       = testPerson,
                    Latitude     = "1",
                    Longitude    = "2",
                    StreetName   = "Katrinebjergvej",
                    StreetNumber = "93B",
                    ZipCode      = 8200,
                    Town         = "Aarhus N"
                }
            }.AsQueryable());

            var uut = new Core.ApplicationServices.PersonService(_personalAddressRepoMock, _addressRepoMock, _employmentsRepoMock, _orgUnitsRepoMock, _routeMock, _coordinatesMock, _loggerMock);
            var res = uut.GetHomeAddress(testPerson);

            Assert.AreEqual(PersonalAddressType.Home, res.Type);
            Assert.AreEqual("Katrinebjergvej", res.StreetName);
            Assert.AreEqual("93B", res.StreetNumber);
            Assert.AreEqual(8200, res.ZipCode);
            Assert.AreEqual("Aarhus N", res.Town);
            _coordinatesMock.DidNotReceiveWithAnyArgs().GetAddressCoordinates(new Address());
        }
        public void ScrubCprsShouldRemoveCprNumbers()
        {
            var uut = new Core.ApplicationServices.PersonService(_personalAddressRepoMock, _addressRepoMock, _employmentsRepoMock, _orgUnitsRepoMock, _routeMock, _coordinatesMock, _loggerMock);

            foreach (var person in _persons)
            {
                Assert.AreNotEqual("", person.CprNumber, "Person should have a CPR number before scrubbing");
            }
            _persons = uut.ScrubCprFromPersons(_persons);
            foreach (var person in _persons)
            {
                Assert.AreEqual("", person.CprNumber, "Person should not have a CPR number before scrubbing");
            }
        }
Example #3
0
        public void GetHomeAddress_WithAlternative_WithNoCoords_ShouldReturnAlternativeHomeAddress_AndCallCoordinates()
        {
            var testPerson = new Person
            {
                Id = 1
            };

            _addressRepoMock.AsQueryable().ReturnsForAnyArgs(new List <PersonalAddress>
            {
                new PersonalAddress
                {
                    Type         = PersonalAddressType.Home,
                    PersonId     = 1,
                    Person       = testPerson,
                    Latitude     = "1",
                    Longitude    = "2",
                    StreetName   = "Katrinebjergvej",
                    StreetNumber = "93B",
                    ZipCode      = 8200,
                    Town         = "Aarhus N"
                },
                new PersonalAddress
                {
                    Type         = PersonalAddressType.AlternativeHome,
                    PersonId     = 1,
                    Person       = testPerson,
                    StreetName   = "Jens Baggesens Vej",
                    StreetNumber = "44",
                    ZipCode      = 8210,
                    Town         = "Aarhus V"
                }
            }.AsQueryable());

            var uut = new Core.ApplicationServices.PersonService(_addressRepoMock, _routeMock, _coordinatesMock, _loggerMock);
            var res = uut.GetHomeAddress(testPerson);

            Assert.AreEqual(PersonalAddressType.AlternativeHome, res.Type);
            Assert.AreEqual("Jens Baggesens Vej", res.StreetName);
            Assert.AreEqual("44", res.StreetNumber);
            Assert.AreEqual(8210, res.ZipCode);
            Assert.AreEqual("Aarhus V", res.Town);
            _coordinatesMock.ReceivedWithAnyArgs().GetAddressCoordinates(new Address());
        }