public void TestThatCreateCreatesSystemProxy(bool hasProperties) { ISystemProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); int number = _fixture.Create <int>(); string title = _fixture.Create <string>(); int? properties = hasProperties ? _fixture.Create <int>() : (int?)null; MySqlDataReader dataReader = CreateMySqlDataReader(number, title, properties); ISystemProxy result = sut.Create(dataReader, CreateMySqlDataProvider(), "SystemNo", "Title", "Properties"); Assert.That(result, Is.Not.Null); Assert.That(result.Nummer, Is.EqualTo(number)); Assert.That(result.Titel, Is.EqualTo(title)); if (hasProperties) { Assert.That(result.Properties, Is.EqualTo(properties)); } else { Assert.That(result.Properties, Is.EqualTo(0)); } dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("SystemNo")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("Title")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetOrdinal(Arg <string> .Is.Equal("Properties")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.IsDBNull(Arg <int> .Is.Equal(2)), opt => opt.Repeat.Once()); if (hasProperties) { dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("Properties")), opt => opt.Repeat.Once()); } else { dataReader.AssertWasNotCalled(m => m.GetInt32(Arg <string> .Is.Equal("Properties"))); } }
public void TestThatCreateThrowsArgumentNullExceptionWhenColumnNameCollectionIsNull() { ISystemProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Create(CreateMySqlDataReader(), CreateMySqlDataProvider(), null)); TestHelper.AssertArgumentNullExceptionIsValid(result, "columnNameCollection"); }
public void TestThatCreateThrowsArgumentNullExceptionWhenDataProviderIsNull() { ISystemProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Create(CreateMySqlDataReader(), null, "SystemNo", "Title", "Properties")); TestHelper.AssertArgumentNullExceptionIsValid(result, "dataProvider"); }