Esempio n. 1
0
        public void UpdateRecordAsync_UpdatesExistingRecordIfItDoesntExists()
        {
            var context = GetContext();

            try
            {
                ProjectUserRepository repo = new ProjectUserRepository(context);
                ProjectUser           rec  = new ProjectUser
                {
                    UserId     = "2138b181-4cee-4b85-9f16-18df308f387d",
                    ProjectId  = 2,
                    UserRoleId = AppUserRole.Observer.Id
                };

                repo.UpdateRecordAsync(rec).Wait();

                var rc = repo.GetRecordAsync("2138b181-4cee-4b85-9f16-18df308f387d", 2).Result;

                Assert.Equal(4, context.ProjectUsers.Count());
                Assert.Equal(AppUserRole.Observer.Id, rc.UserRoleId);
            }
            finally
            {
                context.Database.EnsureDeleted();
                context.Dispose();
            }
        }