public void AddExternal_Should_Throw_InvalidPolicyConfigurationException_IfHostArgumentIsNotProvided()
        {
            // Arrange
            var policyBuilder = new PolicyBuilder <object>();

            // Act
            Action act = () => policyBuilder.AddExternalUri(o => o, string.Empty, null);

            // Assert
            act.Should().Throw <InvalidPolicyConfigurationException>()
            .WithMessage("External Policy requires 'host' argument.");
        }
        public void AddExternal_Should_Throw_InvalidPolicyConfigurationExceptionIfLinkKeyArgumentIsNotProvided()
        {
            // Arrange
            var policyBuilder = new PolicyBuilder <object>();

            // Act
            Action act = () => policyBuilder.AddExternalUri(o => o, "https://google.com", null);

            // Assert
            act.Should().Throw <InvalidPolicyConfigurationException>()
            .WithMessage("External Policy requires 'linkKey' argument.");
        }
Exemple #3
0
        public void InMemoryPolicyRepository_Should_AddExternalUri_ToInMemoryDictionary()
        {
            // Arrange
            var policy = new PolicyBuilder <InMemoryTestViewModel>();

            // Act
            policy.AddExternalUri(x => x.Title, "https://google.com", "Google Link");

            // Assert
            InMemoryPolicyRepository.InMemoryPolicies
            .First(p => p is InMemoryPolicyRepository.ExternalPolicy)
            .Should()
            .NotBeNull();
        }
        public void AddExternal_Should_AddLinkToPolicyInMemoryRepository()
        {
            // Arrange
            string host          = "https://google.com";
            string linkKey       = "ExternalLink";
            var    policyBuilder = new PolicyBuilder <object>();

            // Act
            policyBuilder.AddExternalUri(o => o, host, linkKey);

            // Assert
            InMemoryPolicyRepository.InMemoryPolicies
            .Any(p => p is InMemoryPolicyRepository.CustomPolicy)
            .Should().BeTrue();
        }