Ejemplo n.º 1
0
        public void BulkPersonUpdate()
        {
            var ops        = new SqlOperations(TestCatalog);
            var peopleList = new List <Person>(MockedPersonList());

            ops.AddPersonList(peopleList);

            var personOneId = peopleList[0].Id;

            peopleList[0].FirstName = "Betty";
            peopleList[0].LastName  = "Jones";
            peopleList[0].BirthDay  = new DateTime(1966, 11, 11);

            var personThreeId = peopleList[3].Id;

            peopleList[3].FirstName = "Gary";
            peopleList[3].LastName  = "Smith";
            peopleList[3].BirthDay  = new DateTime(1988, 10, 21);

            Assert.IsTrue(ops.BatchUpdatePeople(peopleList));

            var firstPerson = PersonExists(personOneId);

            Assert.IsTrue(firstPerson.FirstName == "Betty",
                          "Expected Betty");

            var thirdPerson = PersonExists(personThreeId);

            Assert.IsTrue(thirdPerson.FirstName == "Gary",
                          "Expected Gary");
        }
Ejemplo n.º 2
0
        public void AddMultiplePersonsWithBadGender()
        {
            var ops        = new SqlOperations(TestCatalog);
            var peopleList = new List <Person>(MockedPersonList());

            peopleList.FirstOrDefault().Gender = 4;
            ops.AddPersonList(peopleList);
        }
Ejemplo n.º 3
0
        public void AddMultiplePersons()
        {
            // expected primary keys for multiple insert
            var expectedIdentifiers = new int[] { 2001, 2002, 2003, 2004 };

            var ops = new SqlOperations(TestCatalog);

            // Get mocked list of person
            var peopleList = new List <Person>(MockedPersonList());

            // add multiple people
            ops.AddPersonList(peopleList);

            // Get identifiers for newly added records
            var peopleIdentifiers = peopleList.Select(p => p.Id);

            // Validate new primary keys match those in the expected list
            Assert.IsTrue(peopleIdentifiers.ContainsAll(expectedIdentifiers),
                          $"Expected {string.Join(",", expectedIdentifiers)} for multiple inserts but this was not true.");
        }