Example #1
0
		public void GetDataSet_PassDataset_DatasetFilledWithSeveralTabels() {
			var provider = A.Fake<IProvider>();
			var dataAdapter = A.Fake<IDbDataAdapter>();
			var command = A.Fake<ICommand>();
			var dataSource = new DataSource(provider);
			A.CallTo(() => provider.CreateDataAdapter()).Returns(dataAdapter);
			var dataset = new DataSet();
			dataSource.GetDataSet(command, dataset, new []{ "myTable1", "myTable2" });
			A.CallTo(() => dataAdapter.Fill(dataset)).MustHaveHappened(Repeated.Exactly.Once);
			A.CallTo(() => dataAdapter.TableMappings.Add(A<string>.Ignored, "myTable1")).MustHaveHappened(Repeated.Exactly.Once);
			A.CallTo(() => dataAdapter.TableMappings.Add(A<string>.Ignored, "myTable2")).MustHaveHappened(Repeated.Exactly.Once);
		}
Example #2
0
		public void GetDataSet_PassNullCommand_ThrowsArgumentNullException() {
			var provider = A.Fake<IProvider>();
			var dataSource = new DataSource(provider);
			var dataset = new DataSet();
			Assert.Throws<ArgumentNullException>(() => dataSource.GetDataSet(null, dataset));
		}
Example #3
0
		public void GetDataSet_PassDataset_DatasetFilled() {
			var provider = A.Fake<IProvider>();
			var dataAdapter = A.Fake<IDbDataAdapter>();
			var command = A.Fake<ICommand>();
			var dataSource = new DataSource(provider);
			A.CallTo(() => provider.CreateDataAdapter()).Returns(dataAdapter);
			A.CallTo(() => command.Transaction).Returns(null);
			var dataset = new DataSet();
			dataSource.GetDataSet(command, dataset);
			A.CallTo(() => dataAdapter.Fill(dataset)).MustHaveHappened(Repeated.Exactly.Once);
		}