Пример #1
0
        public void CreateRecordAsync_ThrowsExceptionRecordIfItDoesntExists()
        {
            var context = GetContext();

            try
            {
                ProjectUserRepository repo = new ProjectUserRepository(context);
                ProjectUser           rec  = new ProjectUser
                {
                    UserId     = "421cb65f-a76d-4a73-8a1a-d792f37ef992",
                    ProjectId  = 1,
                    UserRoleId = AppUserRole.Observer.Id
                };

                Assert.ThrowsAsync <InvalidOperationException>(async() =>
                                                               await repo.CreateRecordAsync(rec)).Wait();
            }
            finally
            {
                context.Database.EnsureDeleted();
                context.Dispose();
            }
        }
Пример #2
0
        public void CreateRecordAsync_CreatesNewRecordIfItDoesntExists()
        {
            var context = GetContext();

            try
            {
                ProjectUserRepository repo = new ProjectUserRepository(context);
                ProjectUser           rec  = new ProjectUser
                {
                    UserId     = "421cb65f-a76d-4a73-8a1a-d792f37ef992",
                    ProjectId  = 2,
                    UserRoleId = AppUserRole.Observer.Id
                };

                repo.CreateRecordAsync(rec).Wait();

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