public void Validate_WhenSecurityRepositoryIsNull_ThrowsArgumentNullException() { IClientSecretIdentityCommand sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null)); Assert.That(result.ParamName, Is.EqualTo("securityRepository")); }
public void ToDomain_WhenCalledWithoutClientIdAndClientSecret_ReturnsClientSecretIdentity() { IClientSecretIdentityCommand sut = CreateSut(); IClientSecretIdentity result = sut.ToDomain(); Assert.That(result, Is.TypeOf <ClientSecretIdentity>()); }
public void Validate_WhenCalled_ReturnsValidator() { IClientSecretIdentityCommand sut = CreateSut(); IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _securityRepositoryMock.Object); Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object)); }
public void ToDomain_WhenCalledWithoutClientIdAndClientSecret_ReturnsClientSecretIdentityWhereClientSecretIsNotNullEmptyOrWhiteSpace() { string friendlyName = _fixture.Create <string>(); IClientSecretIdentityCommand sut = CreateSut(friendlyName: friendlyName); IClientSecretIdentity result = sut.ToDomain(); Assert.That(string.IsNullOrWhiteSpace(result.ClientSecret), Is.False); }
public void ToDomain_WhenCalledWithoutClientIdAndClientSecret_ReturnsClientSecretIdentityWithFriendlyNameFromCommand() { string friendlyName = _fixture.Create <string>(); IClientSecretIdentityCommand sut = CreateSut(friendlyName: friendlyName); IClientSecretIdentity result = sut.ToDomain(); Assert.That(result.FriendlyName, Is.EqualTo(friendlyName)); }
public void ToDomain_WhenCalledWithoutClientIdAndClientSecret_ReturnsClientSecretIdentityWithIdentifierFromCommand() { int identifier = _fixture.Create <int>(); IClientSecretIdentityCommand sut = CreateSut(identifier); IClientSecretIdentity result = sut.ToDomain(); Assert.That(result.Identifier, Is.EqualTo(identifier)); }
public void ToDomain_WhenClientSecretIsWhiteSpace_ThrowsArgumentNullException() { IClientSecretIdentityCommand sut = CreateSut(); string clientId = _fixture.Create <string>(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ToDomain(clientId, " ")); Assert.That(result.ParamName, Is.EqualTo("clientSecret")); }
public void ToDomain_WhenCalledWithClientIdAndClientSecret_ReturnsClientSecretIdentity() { IClientSecretIdentityCommand sut = CreateSut(); string clientId = _fixture.Create <string>(); string clientSecret = _fixture.Create <string>(); IClientSecretIdentity result = sut.ToDomain(clientId, clientSecret); Assert.That(result, Is.TypeOf <ClientSecretIdentity>()); }
public void ToDomain_WhenCalledWithClientIdAndClientSecret_ReturnsClientSecretIdentityWithClientSecret() { string friendlyName = _fixture.Create <string>(); IClientSecretIdentityCommand sut = CreateSut(friendlyName: friendlyName); string clientId = _fixture.Create <string>(); string clientSecret = _fixture.Create <string>(); IClientSecretIdentity result = sut.ToDomain(clientId, clientSecret); Assert.That(result.ClientSecret, Is.EqualTo(clientSecret)); }
public void ToDomain_WhenCalledWithoutClientIdAndClientSecret_ReturnsClientSecretIdentityWithClaimsFromCommand() { IEnumerable <Claim> claims = _fixture.CreateMany <Claim>(_random.Next(5, 10)).ToList();; IClientSecretIdentityCommand sut = CreateSut(claims: claims); IClientSecretIdentity result = sut.ToDomain(); foreach (Claim claim in claims) { Assert.That(result.ToClaimsIdentity().Claims.SingleOrDefault(m => string.CompareOrdinal(claim.ValueType, m.ValueType) == 0 && string.CompareOrdinal(claim.Value, m.Value) == 0), Is.Not.Null); } }
public void Validate_WhenCalled_AssertShouldNotBeNullOrWhiteSpaceWasCalledOnStringValidator() { string friendlyName = _fixture.Create <string>(); IClientSecretIdentityCommand sut = CreateSut(friendlyName); sut.Validate(_validatorMockContext.ValidatorMock.Object, _securityRepositoryMock.Object); _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldNotBeNullOrWhiteSpace( It.Is <string>(value => string.CompareOrdinal(value, friendlyName) == 0), It.Is <Type>(type => type == sut.GetType()), It.Is <string>(field => string.Compare(field, "FriendlyName", false) == 0)), Times.Once()); }