public async Task ValidateApplication_SucceedsWhenNameAndClientIdAreValid() { // Arrange var validator = new ApplicationValidator <TestApplication>(new ApplicationErrorDescriber()); var application = CreateApplication(); var manager = CreateTestManager(); // Act var result = await validator.ValidateAsync(manager, application); // Assert Assert.True(result.Succeeded); }
public async Task ValidateApplication_FailsForDuplicateClientIds(string clientId) { // Arrange var validator = new ApplicationValidator <TestApplication>(new ApplicationErrorDescriber()); var application = CreateApplication("ApplicationId", "TestApplication", clientId); var manager = CreateTestManager(duplicateClientId: true); var expectedError = new List <IdentityServiceError> { errorDescriber.DuplicateApplicationClientId(clientId) }; // Act var result = await validator.ValidateAsync(manager, application); // Assert Assert.False(result.Succeeded); Assert.Equal(expectedError, result.Errors, ErrorsComparer.Instance); }
public async Task ValidateApplication_FailsForDuplicateApplicationNames(string name) { // Arrange var validator = new ApplicationValidator <TestApplication>(new ApplicationErrorDescriber()); var application = CreateApplication("ApplicationId", name, Guid.NewGuid().ToString()); var manager = CreateTestManager(duplicateName: true); var expectedError = new List <IdentityServiceError> { errorDescriber.DuplicateApplicationName(name) }; // Act var result = await validator.ValidateAsync(manager, application); // Assert Assert.False(result.Succeeded); Assert.Equal(expectedError, result.Errors, ErrorsComparer.Instance); }