Ejemplo n.º 1
0
		public void CreateSPCommand_CreateCommandWithName_ReturnsCommandWithCorrectSpName() {
			var provider = A.Fake<IProvider>();
			var dataSource = new DataSource(provider);
			var command = dataSource.CreateSPCommand("command");
			Assert.AreEqual(CommandType.StoredProcedure, command.DbCommand.CommandType);
			Assert.AreEqual("command", command.DbCommand.CommandText);
		}
Ejemplo n.º 2
0
		public void CreateSPCommand_CreateSpCommandWithTransaction_ReturnsCommandWithCorrectTransaction() {
			var provider = A.Fake<IProvider>();
			var dataSource = new DataSource(provider);
			var trans = A.Fake<ITransaction>();
			var command = dataSource.CreateSPCommand("command", trans);
			Assert.AreEqual(CommandType.StoredProcedure, command.DbCommand.CommandType);
			Assert.AreEqual("command", command.DbCommand.CommandText);
			Assert.AreEqual(trans.DbTransaction, command.DbCommand.Transaction);
		}
Ejemplo n.º 3
0
		public void CreateSPCommand_CreateSpCommandWithParameters_ReturnsCommandWithCorrectParameters() {
			var provider = A.Fake<IProvider>();
			var dbCommand = A.Fake<IDbCommand>();
			var parameterCollection = A.Fake<IDataParameterCollection>();
			
			A.CallTo(() => provider.CreateCommand()).Returns(dbCommand);
			A.CallTo(() => dbCommand.Parameters).Returns(parameterCollection);


			var dataSource = new DataSource(provider);
			var parameters = A.CollectionOfFake<IDataParameter>(12).ToArray();
			var command = dataSource.CreateSPCommand("command", parameters);

			A.CallTo(() => command.DbCommand.Parameters).Returns(parameterCollection);
			Assert.AreEqual(dbCommand, command.DbCommand);
			Assert.AreEqual(CommandType.StoredProcedure, command.DbCommand.CommandType);
			Assert.AreEqual("command", command.DbCommand.CommandText);
			A.CallTo(() => parameterCollection.Add(A<object>.Ignored)).MustHaveHappened(Repeated.Exactly.Times(12));
		}
Ejemplo n.º 4
0
		public void CreateSPCommand_CreatePlainCommand_ReturnsCommandWithTypeStoredProcedure() {
			var provider = A.Fake<IProvider>();
			var dataSource = new DataSource(provider);
			var command = dataSource.CreateSPCommand();
			Assert.AreEqual(CommandType.StoredProcedure, command.DbCommand.CommandType);
		}