Пример #1
0
		public void AddInParameter_CreateParameterWithNameAndType_CorrectParameterAdded() {
			var dbCommand = A.Fake<IDbCommand>();
			var parameterCollection = A.Fake<IDataParameterCollection>();
			A.CallTo(() => dbCommand.Parameters).Returns(parameterCollection);
			
			IDataParameter parameter = null;

			A.CallTo(() => parameterCollection.Add(A<object>.Ignored)).WithAnyArguments().Invokes(x => parameter = x.GetArgument<IDataParameter>(0)).Returns(1);

			var command = new Command(dbCommand, null, null);

			command.AddInParameter("MyParameter", DbType.AnsiString);

			Assert.IsNotNull(parameter);
			Assert.AreEqual("MyParameter", parameter.ParameterName);
			Assert.AreEqual(DbType.AnsiString, parameter.DbType);
			Assert.AreEqual(ParameterDirection.Input, parameter.Direction);

		}
Пример #2
0
		public void AddInParameter_PassDataRowVersion_CorrectParameterAdded() {
			var dbCommand = A.Fake<IDbCommand>();
			var parameterCollection = A.Fake<IDataParameterCollection>();
			A.CallTo(() => dbCommand.Parameters).Returns(parameterCollection);
			
			IDataParameter parameter = null;

			A.CallTo(() => parameterCollection.Add(A<object>.Ignored)).WithAnyArguments().Invokes(x => parameter = x.GetArgument<IDataParameter>(0)).Returns(1);

			var command = new Command(dbCommand, null, null);

			command.AddInParameter("MyParameter", DbType.DateTime2, "column", DataRowVersion.Proposed);

			Assert.IsNotNull(parameter);
			Assert.AreEqual("MyParameter", parameter.ParameterName);
			Assert.AreEqual(DbType.DateTime2, parameter.DbType);
			Assert.AreEqual("column", parameter.SourceColumn);
			Assert.AreEqual(DataRowVersion.Proposed, parameter.SourceVersion);
			Assert.AreEqual(ParameterDirection.Input, parameter.Direction);

		}