public async Task Not_required_overrides_retrieved_from_session_cache_if_already_looked_up_previously()
        {
            var configuration = new List <NotRequiredOverrideConfiguration>
            {
                new NotRequiredOverrideConfiguration
                {
                    Conditions = new List <NotRequiredCondition>
                    {
                        new NotRequiredCondition
                        {
                            ConditionalCheckField = "Field1",
                            MustEqual             = "Test",
                            Value = "NotTest"
                        }
                    },
                    SectionId  = 1,
                    SequenceId = 2
                }
            };

            _config.Setup(x => x.Value).Returns(configuration);

            var applicationData = new JObject
            {
                ["Field1"] = "Test"
            };

            _apiClient.Setup(x => x.GetApplicationData(_applicationId)).ReturnsAsync(applicationData);

            _sessionService.Setup(x => x.Get <List <NotRequiredOverrideConfiguration> >(_sessionKey)).Returns(configuration);
            _sessionService.Setup(x => x.Set(_sessionKey, configuration));

            _service = new NotRequiredOverridesService(_config.Object, _apiClient.Object, _sessionService.Object);
            var overrides = await _service.GetNotRequiredOverridesAsync(_applicationId);

            overrides[0].Conditions[0].Value.Should().Be("NotTest");
            overrides[0].AllConditionsMet.Should().BeFalse();
        }
        public async Task Not_required_overrides_populated_with_answers_from_question_tags()
        {
            var configuration = new List <NotRequiredOverrideConfiguration>
            {
                new NotRequiredOverrideConfiguration
                {
                    Conditions = new List <NotRequiredCondition>
                    {
                        new NotRequiredCondition
                        {
                            ConditionalCheckField = "Field1",
                            MustEqual             = "Test"
                        }
                    },
                    SectionId  = 1,
                    SequenceId = 2
                }
            };

            _config.Setup(x => x.Value).Returns(configuration);

            var applicationData = new JObject
            {
                ["Field1"] = "Test"
            };

            _apiClient.Setup(x => x.GetApplicationData(_applicationId)).ReturnsAsync(applicationData);

            _sessionService.Setup(x => x.Get <List <NotRequiredOverrideConfiguration> >(_sessionKey)).ReturnsInOrder(null, configuration);
            _sessionService.Setup(x => x.Set(_sessionKey, configuration));

            _service = new NotRequiredOverridesService(_config.Object, _apiClient.Object, _sessionService.Object);
            var overrides = await _service.GetNotRequiredOverridesAsync(_applicationId);

            overrides[0].Conditions[0].Value.Should().Be("Test");
            overrides[0].AllConditionsMet.Should().BeTrue();
        }
        public async Task Not_required_overrides_unchanged_if_no_matching_tags_in_application_data()
        {
            var configuration = new List <NotRequiredOverrideConfiguration>
            {
                new NotRequiredOverrideConfiguration
                {
                    Conditions = new List <NotRequiredCondition>
                    {
                        new NotRequiredCondition
                        {
                            ConditionalCheckField = "Field2",
                            MustEqual             = "Value"
                        }
                    },
                    SectionId  = 1,
                    SequenceId = 2
                }
            };

            _config.Setup(x => x.Value).Returns(configuration);

            var applicationData = new JObject
            {
                ["Field1"] = "Test"
            };

            _apiClient.Setup(x => x.GetApplicationData(_applicationId)).ReturnsAsync(applicationData);

            _sessionService.Setup(x => x.Get <List <NotRequiredOverrideConfiguration> >(_sessionKey)).ReturnsInOrder(null, configuration);
            _sessionService.Setup(x => x.Set(_sessionKey, configuration));

            _service = new NotRequiredOverridesService(_config.Object, _apiClient.Object, _sessionService.Object);
            var overrides = await _service.GetNotRequiredOverridesAsync(_applicationId);

            overrides[0].Conditions[0].Value.Should().BeEmpty();
            overrides[0].AllConditionsMet.Should().BeFalse();
        }