Example #1
0
        public void Merges_with_other_ConventionBasedListConfiguration_adding_other_s_conventions_to_the_end()
        {
            testing.Add("result1");
            testingOther.Add("result2");

            testing.Merge(testingOther);

            var actual = testing.Get(type.of <string>());

            Assert.AreEqual(2, actual.Count);
            Assert.AreEqual("result1", actual[0]);
            Assert.AreEqual("result2", actual[1]);
        }
Example #2
0
        public void When_merging_conventions_from_different_configuration__current_layer_is_added_to_given_conventions()
        {
            testing.Add(new[] { "result1" });

            SetMoreSpecificLayer();

            testingOtherConfig.Add(new[] { "result2" });

            testing.Merge(testingOtherConfig);

            var actual = testing.Get(type.of <string>());

            Assert.AreEqual(2, actual.Count);
            Assert.AreEqual("result2", actual[0]);
            Assert.AreEqual("result1", actual[1]);
        }
Example #3
0
        public void When_set__convention_result_is_cached_for_a_given_input()
        {
            testing = new ConventionBasedListConfiguration <ILayered, IType, string>(layeredMock.Object, "test", true);

            var conventionMock = new Mock <IConvention <IType, List <string> > >();

            conventionMock.Setup(o => o.AppliesTo(It.IsAny <IType>())).Returns(true);
            conventionMock.Setup(o => o.Apply(It.IsAny <IType>())).Returns((IType s) => new List <string> {
                s.FullName
            });

            testing.Add(conventionMock.Object);

            testing.Get(type.of <string>());
            testing.Get(type.of <string>());
            testing.Get(type.of <int>());

            conventionMock.Verify(o => o.AppliesTo(type.of <string>()), Times.Once);
            conventionMock.Verify(o => o.Apply(type.of <string>()), Times.Once);
            conventionMock.Verify(o => o.AppliesTo(type.of <int>()), Times.Once);
            conventionMock.Verify(o => o.Apply(type.of <int>()), Times.Once);
        }
Example #4
0
        public void Returns_directly_given_convention_s_result()
        {
            testing.Add(new[] { "result1", "result2" });

            var actual = testing.Get(type.of <string>());

            Assert.AreEqual(2, actual.Count);
            Assert.AreEqual("result1", actual[0]);
            Assert.AreEqual("result2", actual[1]);
        }
Example #5
0
 public static TConfiguration Add <TConfiguration, TFrom, TItem>(
     this ConventionBasedListConfiguration <TConfiguration, TFrom, TItem> source,
     Func <ConventionBuilder <TFrom, List <TItem> >, IConvention <TFrom, List <TItem> > > conventionDelegate
     ) where TConfiguration : ILayered =>
 source.Add(conventionDelegate(BuildRoutine.Convention <TFrom, List <TItem> >()));