public void IsCacheable_is_true_for_queries_without_non_determtsinistic_functions()
        {
            var commandDefinition = new CachingCommandDefinition(
                new Mock<DbCommandDefinition>().Object,
                new CommandTreeFacts(null, true, false),
                new Mock<CacheTransactionHandler>(Mock.Of<ICache>()).Object,
                Mock.Of<CachingPolicy>());

            Assert.True(commandDefinition.IsQuery);
            Assert.True(commandDefinition.IsCacheable);
        }
Ejemplo n.º 2
0
        public void IsCacheable_is_true_for_queries_without_non_determtsinistic_functions()
        {
            var commandDefinition = new CachingCommandDefinition(
                new Mock <DbCommandDefinition>().Object,
                new CommandTreeFacts(null, true, false),
                new Mock <CacheTransactionHandler>(Mock.Of <ICache>()).Object,
                Mock.Of <CachingPolicy>());

            Assert.True(commandDefinition.IsQuery);
            Assert.True(commandDefinition.IsCacheable);
        }
        public void Ctor_sets_parameters()
        {
            var entityType = EntityType.Create("Entity", "ns", DataSpace.CSpace, new string[0], new EdmMember[0], null);
            var entitySet = EntitySet.Create("EntitySet", "ns", null, null, entityType, null);

            var commandDefinition = new CachingCommandDefinition(
                new Mock<DbCommandDefinition>().Object,
                new CommandTreeFacts(
                    new List<EntitySetBase> { entitySet }.AsReadOnly(), true, true),
                new Mock<CacheTransactionHandler>(Mock.Of<ICache>()).Object,
                Mock.Of<CachingPolicy>());

            Assert.Equal(new[] { entitySet }, commandDefinition.AffectedEntitySets);
            Assert.True(commandDefinition.IsQuery);
            Assert.False(commandDefinition.IsCacheable);
        }
Ejemplo n.º 4
0
        public void Ctor_sets_parameters()
        {
            var entityType = EntityType.Create("Entity", "ns", DataSpace.CSpace, new string[0], new EdmMember[0], null);
            var entitySet  = EntitySet.Create("EntitySet", "ns", null, null, entityType, null);

            var commandDefinition = new CachingCommandDefinition(
                new Mock <DbCommandDefinition>().Object,
                new CommandTreeFacts(
                    new List <EntitySetBase> {
                entitySet
            }.AsReadOnly(), true, true),
                new Mock <CacheTransactionHandler>(Mock.Of <ICache>()).Object,
                Mock.Of <CachingPolicy>());

            Assert.Equal(new[] { entitySet }, commandDefinition.AffectedEntitySets);
            Assert.True(commandDefinition.IsQuery);
            Assert.False(commandDefinition.IsCacheable);
        }
        public void CreateCommand_creates_CachingCommand()
        {
            var mockCommandDefinition = new Mock<DbCommandDefinition>();
            mockCommandDefinition
                .Setup(d => d.CreateCommand())
                .Returns(new Mock<DbCommand>().Object);

            var commandDefintion =
                new CachingCommandDefinition(
                    mockCommandDefinition.Object,
                    new CommandTreeFacts(null, true, false),
                    new Mock<CacheTransactionHandler>(Mock.Of<ICache>()).Object,
                    Mock.Of<CachingPolicy>())
                .CreateCommand();

            Assert.IsType<CachingCommand>(commandDefintion);

            mockCommandDefinition.Verify(d => d.CreateCommand(), Times.Once);
        }
Ejemplo n.º 6
0
        public void CreateCommand_creates_CachingCommand()
        {
            var mockCommandDefinition = new Mock <DbCommandDefinition>();

            mockCommandDefinition
            .Setup(d => d.CreateCommand())
            .Returns(new Mock <DbCommand>().Object);

            var commandDefintion =
                new CachingCommandDefinition(
                    mockCommandDefinition.Object,
                    new CommandTreeFacts(null, true, false),
                    new Mock <CacheTransactionHandler>(Mock.Of <ICache>()).Object,
                    Mock.Of <CachingPolicy>())
                .CreateCommand();

            Assert.IsType <CachingCommand>(commandDefintion);

            mockCommandDefinition.Verify(d => d.CreateCommand(), Times.Once);
        }