예제 #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);
		}
예제 #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);
		}
예제 #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));
		}
예제 #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);
		}