Exemple #1
0
        public void SslamSearchRequest_WhenMappedToPagedSearchRequest_CorrectlyAssignsSearchParameterValuesToSearchRequestParameterObjects()
        {
            // ARRANGE
            var settingsContainer = DIOptionsHelper.SetupOptionsContainerBuilder();
            var searchRequest     = MockSearchRequests.GetGoalsSearchRequestWithSlaRecordVolumeAndStateOfCalifornia();

            // ACT
            using (var scope = settingsContainer.BeginLifetimeScope())
            {
                var optionsSnapshot     = scope.Resolve <IOptions <SslamPagedSearchSettings> >();
                var sslamSearchSettings = optionsSnapshot.Value;

                var mappedSearchRequest = Mapper.Map <PagedSearchRequest>(sslamSearchSettings);

                // assign searchRequest values to the matching Parameter object Value properties
                MapSearchRequestToPagedSearchRequestParameters.MapSearchRequest(searchRequest, mappedSearchRequest);

                // ASSERT

                foreach (PropertyInfo propertyInfo in searchRequest.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var propertyName         = propertyInfo.Name;
                        var pagedSearchParameter = mappedSearchRequest.Parameters.Find(p =>
                                                                                       string.Equals(p.Name.ToLower(), propertyName.ToLower()));

                        if (pagedSearchParameter != null)
                        {
                            Assert.True(((IComparable)pagedSearchParameter.Value).CompareTo((IComparable)propertyInfo.GetValue(searchRequest)) == 0, "Search Request value and Paged Search Parameter value match.");
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void SlaMetricSearchSettings_WhenDependencyRequested_ReturnsAValidObject()
        {
            // ARRANGE
            var settingsContainer = DIOptionsHelper.SetupOptionsContainerBuilder();

            // ACT
            using (var scope = settingsContainer.BeginLifetimeScope())
            {
                var optionsSnapshot     = scope.Resolve <IOptions <SslamPagedSearchSettings> >();
                var sslamSearchSettings = optionsSnapshot.Value;

                // ASSERT
                Assert.NotNull(sslamSearchSettings);
                Assert.True(sslamSearchSettings.Parameters.Count == 16);
                Assert.True(sslamSearchSettings.ColumnConfigurations.Count == 10);
                Assert.True(!string.IsNullOrWhiteSpace(sslamSearchSettings.SearchStoredProcedure));
                Assert.True(!string.IsNullOrWhiteSpace(sslamSearchSettings.SearchResultSetType));

                // Validate the Sslam Search Settings model
                var context           = new ValidationContext(sslamSearchSettings, serviceProvider: null, items: null);
                var validationResults = new List <ValidationResult>();

                bool isValid = Validator.TryValidateObject(sslamSearchSettings, context, validationResults, true);
                Assert.True(isValid, "Sslam Settings are valid");
            }
        }
Exemple #3
0
        public void SslamPagedSearchSettings_WhenManuallyValidated_IsValid()
        {
            // ARRANGE
            var settingsContainer = DIOptionsHelper.SetupOptionsContainerBuilder();

            // ACT
            using (var scope = settingsContainer.BeginLifetimeScope())
            {
                var optionsSnapshot     = scope.Resolve <IOptions <SslamPagedSearchSettings> >();
                var sslamSearchSettings = optionsSnapshot.Value;

                var validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(sslamSearchSettings, serviceProvider: null, items: null);
                var validationResults = new List <ValidationResult>();

                bool isValid = Validator.TryValidateObject(sslamSearchSettings, validationContext, validationResults, true);

                // ASSERT

                Assert.True(isValid, "Default Sslam search settings are valid.");
            }
        }
Exemple #4
0
        public void SslamPagedSearchSettings_WhenDependencyRequested_ReturnsValidColumnConfigurations()
        {
            // ARRANGE
            var settingsContainer = DIOptionsHelper.SetupOptionsContainerBuilder();

            // ACT
            using (var scope = settingsContainer.BeginLifetimeScope())
            {
                var optionsSnapshot     = scope.Resolve <IOptions <SslamPagedSearchSettings> >();
                var sslamSearchSettings = optionsSnapshot.Value;

                // ASSERT

                // verify that each property of the column configurations are populated
                foreach (var columnConfiguration in sslamSearchSettings.ColumnConfigurations)
                {
                    Assert.True(!string.IsNullOrWhiteSpace(columnConfiguration.ColumnHeader), "Column header is present");
                    Assert.True(!string.IsNullOrWhiteSpace(columnConfiguration.ColumnBinding), $"Column binding for {columnConfiguration.ColumnHeader} is present");
                }
            }
        }
Exemple #5
0
        public void SlaMetricSearchSettings_WhenDependencyRequestedAndDataAnnotationValidated_ReturnsValidSettings()
        {
            // ARRANGE
            var settingsContainer = DIOptionsHelper.SetupOptionsContainerBuilder();

            // ACT
            using (var scope = settingsContainer.BeginLifetimeScope())
            {
                var optionsSnapshot     = scope.Resolve <IOptions <SslamPagedSearchSettings> >();
                var sslamSearchSettings = optionsSnapshot.Value;

                // ASSERT

                // Validate the Sslam Search Settings model
                var context           = new ValidationContext(sslamSearchSettings, serviceProvider: null, items: null);
                var validationResults = new List <ValidationResult>();

                bool isValid = Validator.TryValidateObject(sslamSearchSettings, context, validationResults, true);
                Assert.True(isValid, "Sslam Settings are valid");
            }
        }
Exemple #6
0
        public void SslamPagedSearchSettings_WhenDependencyRequested_ReturnsValidParameters()
        {
            // ARRANGE
            var settingsContainer = DIOptionsHelper.SetupOptionsContainerBuilder();

            // ACT
            using (var scope = settingsContainer.BeginLifetimeScope())
            {
                var optionsSnapshot     = scope.Resolve <IOptions <SslamPagedSearchSettings> >();
                var sslamSearchSettings = optionsSnapshot.Value;

                // ASSERT

                // verify that each property of the parameters are populated
                foreach (var parameter in sslamSearchSettings.Parameters)
                {
                    Assert.True(!string.IsNullOrWhiteSpace(parameter.Name), "Parameter name is present");
                    Assert.True(Enum.IsDefined(typeof(DbType), parameter.DbDataType), $"Parameter data type for {parameter.Name} is valid");
                    Assert.True(parameter.IsNullable || parameter.IsNullable == false, $"Parameter for {parameter.Name} IsNullable is set");
                }
            }
        }
Exemple #7
0
        public void SslamPagedSearchSettings_WhenMapped_ResultsInAValidPagedSearchRequest()
        {
            // ARRANGE
            var settingsContainer = DIOptionsHelper.SetupOptionsContainerBuilder();

            // ACT
            using (var scope = settingsContainer.BeginLifetimeScope())
            {
                var optionsSnapshot     = scope.Resolve <IOptions <SslamPagedSearchSettings> >();
                var sslamSearchSettings = optionsSnapshot.Value;

                var mappedSearchRequest = Mapper.Map <PagedSearchRequest>(sslamSearchSettings);

                // ASSERT

                Assert.NotNull(mappedSearchRequest);
                Assert.True(mappedSearchRequest.Parameters.Count == 16);
                Assert.True(mappedSearchRequest.ColumnConfigurations.Count == 10);
                Assert.True(!string.IsNullOrWhiteSpace(mappedSearchRequest.SearchStoredProcedure));
                Assert.True(!string.IsNullOrWhiteSpace(mappedSearchRequest.SearchResultSetType));
            }
        }