Example #1
0
        public void InsuranceRoundTripsToDatabase()
        {
            var newInsureeId = 0;
            var insuree      = SimpleInsureeTests.CreateInsuree();

            var insurance = CreateInsurance();

            insuree.Insurances.Add(insurance);

            using (new UnitOfWorkFactory().Create())
            {
                var repository = new InsureeRepository();
                repository.Add(insuree);
            }
            insuree.Id.Should().BePositive();
            newInsureeId = insuree.Id;

            using (new UnitOfWorkFactory().Create())
            {
                var repository = new InsureeRepository();
                var check      = repository.FindById(newInsureeId);
                check.Id.Should().Be(newInsureeId);

                check.Insurances.Count.Should().Be(1);
                check.Insurances[0].Id.Should().Be(insurance.Id);
                check.Insurances[0].InsuranceNumber.ShouldBeEquivalentTo(insurance.InsuranceNumber);
                check.Insurances[0].StartDate.ShouldBeEquivalentTo(insurance.StartDate);
            }
        }
Example #2
0
        public void AddressTypeRoundtripsToDatabase()
        {
            var newInsureeId = 0;
            var insuree      = SimpleInsureeTests.CreateInsuree();

            var address = CreateAddress(ContactType.Personal);

            insuree.Addresses.Add(address);

            address = CreateAddress(ContactType.Business);
            insuree.Addresses.Add(address);

            using (new UnitOfWorkFactory().Create())
            {
                var repository = new InsureeRepository();
                repository.Add(insuree);
            }
            insuree.Id.Should().BePositive();
            newInsureeId = insuree.Id;

            using (new UnitOfWorkFactory().Create())
            {
                var repository = new InsureeRepository();
                var check      = repository.FindById(newInsureeId);
                check.Id.Should().Be(newInsureeId);

                check.Addresses.Count().Should().Be(2);
                check.Addresses[0].ContactType.Should().Be(ContactType.Personal);
                check.Addresses[1].ContactType.Should().Be(ContactType.Business);
            }
        }