Esempio n. 1
0
        /// <summary>
        /// We expect scheduled day off to NOT be updated, since it's not a property of UserEditableSettings
        /// </summary>
        public void TestUpdateUsingGenericLimitedFieldsAsync()
        {
            using (var connection = GetOpenConnection())
            {
                //arrange
                var user = new User { Name = "User1", Age = 10, ScheduledDayOff = DayOfWeek.Friday };
                user.Id = connection.Insert(user) ?? 0;

                user.ScheduledDayOff = DayOfWeek.Thursday;
                var userAsEditableSettings = (UserEditableSettings)user;
                userAsEditableSettings.Name = "User++";

                connection.UpdateAsync(userAsEditableSettings).Wait();

                //act
                var insertedUser = connection.Get<User>(user.Id);

                //assert
                insertedUser.Name.IsEqualTo("User++");
                insertedUser.ScheduledDayOff.IsEqualTo(DayOfWeek.Friday);

                connection.Delete<User>(user.Id);
            }
        }
Esempio n. 2
0
        public void TestInsertUsingGenericLimitedFieldsAsync()
        {
            using (var connection = GetOpenConnection())
            {
                //arrange
                var user = new User { Name = "User1", Age = 10, ScheduledDayOff = DayOfWeek.Friday };

                //act
                var idTask = connection.InsertAsync<int?, UserEditableSettings>(user);
                idTask.Wait();
                var id = idTask.Result;

                //assert
                var insertedUser = connection.Get<User>(id);
                insertedUser.ScheduledDayOff.IsNull();

                connection.Delete<User>(id);
            }
        }