Beispiel #1
0
		public void UpdateDataSet_PassingNullDataSet_ThrowsArgumentNullExeption() {
			var provider = A.Fake<IProvider>();
			var dataSource = new DataSource(provider);

			var insertCommand = A.Fake<ICommand>();
			var updateCommand = A.Fake<ICommand>();
			var deleteCommand = A.Fake<ICommand>();

			Assert.Throws<ArgumentNullException>(() => dataSource.UpdateDataSet(null, insertCommand, updateCommand, deleteCommand));

		}
Beispiel #2
0
		public void UpdateDataSet_PassAdapter_AddapterGetCommands() {
			var provider = A.Fake<IProvider>();
			var dataAdapter = A.Fake<IDbDataAdapter>();
			var dataSource = new DataSource(provider);
			A.CallTo(() => provider.CreateDataAdapter()).Returns(dataAdapter);

			var insertCommand = A.Fake<ICommand>();
			var updateCommand = A.Fake<ICommand>();
			var deleteCommand = A.Fake<ICommand>();

			var dataset = new DataSet();
			dataSource.UpdateDataSet(dataset, insertCommand, updateCommand, deleteCommand, "myTable");

			A.CallTo(() => dataAdapter.TableMappings.Add(A<string>.Ignored, "myTable")).MustHaveHappened(Repeated.Exactly.Once);
			Assert.AreEqual(insertCommand.DbCommand, dataAdapter.InsertCommand);
			Assert.AreEqual(updateCommand.DbCommand, dataAdapter.UpdateCommand);
			Assert.AreEqual(deleteCommand.DbCommand, dataAdapter.DeleteCommand);
		}
Beispiel #3
0
		public void UpdateDataSet_PassingNullTransaction_ThrowsArgumentNullExeption() {
			var provider = A.Fake<IProvider>();
			var dataSource = new DataSource(provider);

			var insertCommand = A.Fake<ICommand>();
			var updateCommand = A.Fake<ICommand>();
			var deleteCommand = A.Fake<ICommand>();

			var dataset = new DataSet();
			Assert.Throws<ArgumentNullException>(() => dataSource.UpdateDataSet(dataset, insertCommand, updateCommand, deleteCommand, "myTable", null));

		}
Beispiel #4
0
		public void UpdateDataSet_PassAdapter_UpdateOnAdapterCalled() {
			var provider = A.Fake<IProvider>();
			var dataAdapter = A.Fake<IDbDataAdapter>();
			var dataSource = new DataSource(provider);
			A.CallTo(() => provider.CreateDataAdapter()).Returns(dataAdapter);

			var insertCommand = A.Fake<ICommand>();
			var updateCommand = A.Fake<ICommand>();
			var deleteCommand = A.Fake<ICommand>();

			var dataset = new DataSet();
			dataSource.UpdateDataSet(dataset, insertCommand, updateCommand, deleteCommand);

			A.CallTo(() => dataAdapter.Update(dataset)).MustHaveHappened(Repeated.Exactly.Once);
		}