public async Task Invalidate_request_when_no_user_found_by_sub(string sub) { // Arrange var sut = new DeleteCertificationValidator(_dbContext); // Act bool isValid = await sut.IsValidAsync(new DeleteCertification(sub, Guid.NewGuid())); // Assert isValid.ShouldBeFalse(); }
public async Task Invalidate_request_when_user_is_not_owner() { // Arrange var sut = new DeleteCertificationValidator(_dbContext); var certificationId = Guid.NewGuid(); var ownerId = Guid.NewGuid(); var ownerSub = Guid.NewGuid().ToString(); var userSub = Guid.NewGuid().ToString(); var owner = new User { FirstName = "Integration", LastName = "Test", Sub = ownerSub, Id = ownerId }; var certification = new Domain.Entities.Certification { Id = certificationId, Name = "my certification", User = owner, IssuingAuthority = "test authority" }; await _dbContext.Users.AddAsync(owner); await _dbContext.Certifications.AddAsync(certification); await _dbContext.SaveChangesAsync(); // Act bool isValid = await sut.IsValidAsync(new DeleteCertification(userSub, certificationId)); // Assert isValid.ShouldBeFalse(); }
public async Task Invalidate_request_when_certification_not_found() { // Arrange var sut = new DeleteCertificationValidator(_dbContext); string userSub = Guid.NewGuid().ToString(); var user = new User { FirstName = "Integration", LastName = "Test", Sub = userSub }; await _dbContext.Users.AddAsync(user); await _dbContext.SaveChangesAsync(); // Act bool isValid = await sut.IsValidAsync(new DeleteCertification(userSub, Guid.NewGuid())); // Assert isValid.ShouldBeFalse(); }