public void Create_returns_new_instances()
        {
            var factory = new ModificationCommandBatchFactory(new Mock <SqlGenerator>().Object);

            var firstBatch  = factory.Create();
            var secondBatch = factory.Create();

            Assert.NotNull(firstBatch);
            Assert.NotNull(secondBatch);
            Assert.NotSame(firstBatch, secondBatch);
        }
        public void AddCommand_delegates()
        {
            var sqlGenerator = new Mock <SqlGenerator>().Object;
            var factory      = new ModificationCommandBatchFactory(sqlGenerator);

            var modificationCommandBatchMock = new Mock <ModificationCommandBatch>();
            var mockModificationCommand      = new Mock <ModificationCommand>().Object;

            factory.AddCommand(modificationCommandBatchMock.Object, mockModificationCommand);

            modificationCommandBatchMock.Verify(mcb => mcb.AddCommand(mockModificationCommand, sqlGenerator));
        }
Esempio n. 3
0
        protected CommandBatchPreparer(
            [NotNull] ModificationCommandBatchFactory modificationCommandBatchFactory,
            [NotNull] ParameterNameGeneratorFactory parameterNameGeneratorFactory,
            [NotNull] ModificationCommandComparer modificationCommandComparer)
        {
            Check.NotNull(modificationCommandBatchFactory, "modificationCommandBatchFactory");
            Check.NotNull(parameterNameGeneratorFactory, "parameterNameGeneratorFactory");
            Check.NotNull(modificationCommandComparer, "modificationCommandComparer");

            _modificationCommandBatchFactory = modificationCommandBatchFactory;
            _parameterNameGeneratorFactory   = parameterNameGeneratorFactory;
            _modificationCommandComparer     = modificationCommandComparer;
        }
        public void Create_returns_new_instances()
        {
            var factory = new ModificationCommandBatchFactory(
                new Mock<SqlGenerator>().Object, 
                new Mock<DbContextConfiguration>().Object);

            var firstBatch = factory.Create();
            var secondBatch = factory.Create();

            Assert.NotNull(firstBatch);
            Assert.NotNull(secondBatch);
            Assert.NotSame(firstBatch, secondBatch);
        }
        public void AddCommand_delegates()
        {
            var sqlGenerator = new Mock<SqlGenerator>().Object;
            var factory = new ModificationCommandBatchFactory(
                sqlGenerator,
                new Mock<DbContextConfiguration>().Object);

            var modificationCommandBatchMock = new Mock<ModificationCommandBatch>();
            var mockModificationCommand = new Mock<ModificationCommand>().Object;

            factory.AddCommand(modificationCommandBatchMock.Object, mockModificationCommand);

            modificationCommandBatchMock.Verify(mcb => mcb.AddCommand(mockModificationCommand, sqlGenerator));
        }
        public void AddCommand_checks_arguments()
        {
            var factory = new ModificationCommandBatchFactory(new Mock <SqlGenerator>().Object);

            Assert.Equal(
                "modificationCommandBatch",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws <ArgumentNullException>(() =>
                                                      factory.AddCommand(null, new Mock <ModificationCommand>().Object)).ParamName);

            Assert.Equal(
                "modificationCommand",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws <ArgumentNullException>(() =>
                                                      factory.AddCommand(new Mock <ModificationCommandBatch>().Object, null)).ParamName);
        }
        protected CommandBatchPreparer(
            [NotNull] ModificationCommandBatchFactory modificationCommandBatchFactory,
            [NotNull] ParameterNameGeneratorFactory parameterNameGeneratorFactory,
            [NotNull] ModificationCommandComparer modificationCommandComparer,
            [NotNull] IBoxedValueReaderSource boxedValueReaderSource)
        {
            Check.NotNull(modificationCommandBatchFactory, nameof(modificationCommandBatchFactory));
            Check.NotNull(parameterNameGeneratorFactory, nameof(parameterNameGeneratorFactory));
            Check.NotNull(modificationCommandComparer, nameof(modificationCommandComparer));
            Check.NotNull(boxedValueReaderSource, nameof(boxedValueReaderSource));

            _modificationCommandBatchFactory = modificationCommandBatchFactory;
            _parameterNameGeneratorFactory   = parameterNameGeneratorFactory;
            _modificationCommandComparer     = modificationCommandComparer;
            _boxedValueReaderSource          = boxedValueReaderSource;
        }
        public void AddCommand_checks_arguments()
        {
            var factory = new ModificationCommandBatchFactory(
                new Mock<SqlGenerator>().Object,
                new Mock<DbContextConfiguration>().Object);

            Assert.Equal(
                "modificationCommandBatch",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() =>
                    factory.AddCommand(null, new Mock<ModificationCommand>().Object)).ParamName);

            Assert.Equal(
                "modificationCommand",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() =>
                    factory.AddCommand(new Mock<ModificationCommandBatch>().Object, null)).ParamName);
        }
 public TestCommandBatchPreparer(
     ModificationCommandBatchFactory modificationCommandBatchFactory,
     ParameterNameGeneratorFactory parameterNameGeneratorFactory,
     ModificationCommandComparer modificationCommandComparer,
     IBoxedValueReaderSource boxedValueReaderSource)
     : base(modificationCommandBatchFactory, parameterNameGeneratorFactory, modificationCommandComparer, boxedValueReaderSource)
 {
 }
        private static CommandBatchPreparer CreateCommandBatchPreparer(ModificationCommandBatchFactory modificationCommandBatchFactory = null)
        {
            modificationCommandBatchFactory =
                modificationCommandBatchFactory ?? new TestModificationCommandBatchFactory(new Mock<ISqlGenerator>().Object);

            return new TestCommandBatchPreparer(modificationCommandBatchFactory,
                new ParameterNameGeneratorFactory(),
                new ModificationCommandComparer(),
                new BoxedValueReaderSource());
        }
 private static CommandBatchPreparer CreateCommandBatchPreparer(ModificationCommandBatchFactory modificationCommandBatchFactory = null)
 {
     return new CommandBatchPreparer(
         modificationCommandBatchFactory ?? new ModificationCommandBatchFactory(new Mock<SqlGenerator> { CallBase = true }.Object, new Mock<DbContextConfiguration>().Object),
         new ParameterNameGeneratorFactory(),
         new BidirectionalAdjacencyListGraphFactory(),
         new ModificationCommandComparer());
 }