Exemple #1
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);
        }
Exemple #2
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]);
        }