Ejemplo 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();
            }
        }
Ejemplo n.º 2
0
        public void GetRecordAsync_ReturnsNullIfRecordDoesntExists()
        {
            var context = GetContext();

            try
            {
                ProjectUserRepository repo = new ProjectUserRepository(context);

                ProjectUser rec = repo.GetRecordAsync("no-user", 1).Result;

                Assert.Null(rec);
            }
            finally
            {
                context.Database.EnsureDeleted();
                context.Dispose();
            }
        }
Ejemplo n.º 3
0
        public void GetRecordAsync_ReturnsRecordIfRecordExists()
        {
            AppDbContext context = GetContext();

            try
            {
                ProjectUserRepository repo = new ProjectUserRepository(context);

                ProjectUser rec = repo.GetRecordAsync("2138b181-4cee-4b85-9f16-18df308f387d", 1).Result;

                Assert.NotNull(rec);
            }
            finally
            {
                context.Database.EnsureDeleted();
                context.Dispose();
            }
        }
Ejemplo n.º 4
0
        public void DeleteRecordAsync_DeletesNewRecordIfItExists()
        {
            var context = GetContext();

            try
            {
                ProjectUserRepository repo = new ProjectUserRepository(context);
                ProjectUser           rec  = repo.GetRecordAsync("2138b181-4cee-4b85-9f16-18df308f387d", 2).Result;

                repo.DeleteRecordAsync(rec).Wait();

                Assert.Equal(3, context.ProjectUsers.Count());
            }
            finally
            {
                context.Database.EnsureDeleted();
                context.Dispose();
            }
        }