Exemplo n.º 1
0
        public void TestAddress_CreatePerson_ThenAddresses()
        {
            var person = new Person
            {
                Name        = "New Person",
                Nationality = "Irish"
            };

            var actual   = new PersonRepository(ConnectionString).Create(person);
            var expected = true;

            Assert.IsTrue(actual == expected, $"Create Person: expected: {expected}, but received: {actual}");

            var address1 = new Address
            {
                AnotherId = "Another ID",
                PersonId  = person.Id,
                Line1     = "Line 1",
                PostCode  = "Post Code"
            };
            var address2 = new Address
            {
                AnotherId = "Another 2",
                PersonId  = person.Id,
                Line1     = "Line 1 2",
                PostCode  = "Post Code 2"
            };

            actual = _repository.BulkCreate(new List <Address> {
                address1, address2
            });

            Assert.IsTrue(actual == expected, $"Create addresses: expected: {expected}, but received: {actual}");

            var all = _repository.GetAll().ToArray();

            Assert.IsTrue(all.Length == 12, $"expected: 12 but received: {all.Length}");
        }