Пример #1
0
        public void can_find_a_value_in_multiple_sources()
        {
            var core1 = new SettingsData().With("key1", "val1");
            var core2 = new SettingsData().With("key2", "val2");
            var core3 = new SettingsData().With("key3", "val3");

            var request = SettingsRequestData.For(core1, core2, core3);

            request.Value("key1").ShouldEqual("val1");
            request.Value("key2").ShouldEqual("val2");
            request.Value("key3").ShouldEqual("val3");
        }
Пример #2
0
        public void ForValue_hit()
        {
            var core1 = new SettingsData(SettingCategory.core).With("key1", "core1");

            var requestData = new SettingsRequestData(new SettingsData[] { core1 });

            var action = MockRepository.GenerateMock <Action <string, string> >();

            requestData.ForValue("key1", action).ShouldBeTrue();

            action.AssertWasCalled(x => x.Invoke("key1", "core1"));
        }
Пример #3
0
        public void ForValue_miss()
        {
            var core1 = new SettingsData(SettingCategory.core).With("key1", "core1");

            var requestData = new SettingsRequestData(new SettingsData[] { core1 });

            var action = MockRepository.GenerateMock <Action <string, string> >();

            requestData.ForValue("key2", action).ShouldBeFalse();

            action.AssertWasNotCalled(x => x.Invoke(null, null), x => x.IgnoreArguments());
        }
Пример #4
0
        public void has_any_value_prefixed_with_key()
        {
            var core1 = new SettingsData().With("One.key1", "val1");
            var core2 = new SettingsData().With("Two.key2", "val2");
            var core3 = new SettingsData().With("Three.key3", "val3");

            var request = SettingsRequestData.For(core1, core2, core3);

            request.HasAnyValuePrefixedWith("One").ShouldBeTrue();
            request.HasAnyValuePrefixedWith("Two").ShouldBeTrue();
            request.HasAnyValuePrefixedWith("Three").ShouldBeTrue();
            request.HasAnyValuePrefixedWith("NotInTheRequestDataAnywhere").ShouldBeFalse();
        }
Пример #5
0
        public void value_CPS_style_with_multiple_source_with_no_match()
        {
            var core1 = new SettingsData().With("key1", "val1");
            var core2 = new SettingsData().With("key2", "val2");
            var core3 = new SettingsData().With("key3", "val3");

            var request = SettingsRequestData.For(core1, core2, core3);

            var action = MockRepository.GenerateMock <Action <object> >();

            request.Value("missing key", action).ShouldBeFalse();

            action.AssertWasNotCalled(x => x.Invoke(null), x => x.IgnoreArguments());
        }
Пример #6
0
        public void value_CPS_style_with_multiple_sources_with_a_match()
        {
            var core1 = new SettingsData().With("key1", "val1");
            var core2 = new SettingsData().With("key2", "val2");
            var core3 = new SettingsData().With("key3", "val3");

            var request = SettingsRequestData.For(core1, core2, core3);

            var action = MockRepository.GenerateMock <Action <object> >();

            request.Value("key2", action).ShouldBeTrue();

            action.AssertWasCalled(x => x.Invoke("val2"));
        }