public void TestThatCreateCreatesProxy(bool handlesPayments) { IDataProviderProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); Guid identifier = Guid.NewGuid(); string name = _fixture.Create <string>(); Guid dataSourceStatementIdentifier = Guid.NewGuid(); MySqlDataReader dataReader = CreateMySqlDataReader(identifier, name, handlesPayments, dataSourceStatementIdentifier); IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider(); IDataProviderProxy result = sut.Create(dataReader, dataProvider, "DataProviderIdentifier", "Name", "HandlesPayments", "DataSourceStatementIdentifier"); Assert.That(result, Is.Not.Null); Assert.That(result.Identifier, Is.Not.Null); Assert.That(result.Identifier, Is.EqualTo(identifier)); Assert.That(result.Name, Is.Not.Null); Assert.That(result.Name, Is.Not.Empty); Assert.That(result.Name, Is.EqualTo(name)); Assert.That(result.HandlesPayments, Is.EqualTo(handlesPayments)); Assert.That(result.DataSourceStatementIdentifier, Is.Not.EqualTo(Guid.Empty)); Assert.That(result.DataSourceStatementIdentifier, Is.EqualTo(dataSourceStatementIdentifier)); dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("DataProviderIdentifier")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("Name")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("HandlesPayments")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("DataSourceStatementIdentifier")), opt => opt.Repeat.Once()); dataProvider.AssertWasNotCalled(m => m.Clone()); }
public void TestThatTranslationsMapsTranslationsAndDataSourceStatementsIntoProxyWhenCreateHasBeenCalledAndMapDataHasNotBeenCalled() { IDataProviderProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); Guid dataSourceStatementIdentifier = Guid.NewGuid(); MySqlDataReader dataReader = CreateMySqlDataReader(Guid.NewGuid(), _fixture.Create <string>(), _fixture.Create <bool>(), dataSourceStatementIdentifier); IEnumerable <TranslationProxy> translationProxyCollection = BuildTranslationProxyCollection(dataSourceStatementIdentifier); IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider(translationProxyCollection); IDataProviderProxy result = sut.Create(dataReader, dataProvider, "DataProviderIdentifier", "Name", "HandlesPayments", "DataSourceStatementIdentifier"); Assert.That(result, Is.Not.Null); Assert.That(result.Translation, Is.Null); Assert.That(result.Translations, Is.Not.Null); Assert.That(result.Translations, Is.Not.Empty); Assert.That(result.Translations, Is.EqualTo(translationProxyCollection)); Assert.That(result.DataSourceStatement, Is.Null); Assert.That(result.DataSourceStatements, Is.Not.Null); Assert.That(result.DataSourceStatements, Is.Not.Empty); Assert.That(result.DataSourceStatements, Is.EqualTo(translationProxyCollection)); dataProvider.AssertWasCalled(m => m.Clone(), opt => opt.Repeat.Times(1)); IDbCommandTestExecutor commandTester = new DbCommandTestBuilder("SELECT t.TranslationIdentifier AS TranslationIdentifier,t.OfIdentifier AS OfIdentifier,ti.TranslationInfoIdentifier AS InfoIdentifier,ti.CultureName AS CultureName,t.Value AS Value FROM Translations AS t INNER JOIN TranslationInfos AS ti ON ti.TranslationInfoIdentifier=t.InfoIdentifier WHERE t.OfIdentifier=@ofIdentifier ORDER BY ti.CultureName") .AddCharDataParameter("@ofIdentifier", dataSourceStatementIdentifier) .Build(); dataProvider.AssertWasCalled(m => m.GetCollection <TranslationProxy>(Arg <MySqlCommand> .Matches(cmd => commandTester.Run(cmd))), opt => opt.Repeat.Once()); }
public void TestThatCreateThrowsArgumentNullExceptionIfColumnNameCollectionIsNull() { IDataProviderProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Create(CreateMySqlDataReader(), CreateFoodWasteDataProvider(), null)); TestHelper.AssertArgumentNullExceptionIsValid(result, "columnNameCollection"); }
public void TestThatCreateThrowsArgumentNullExceptionIfDataProviderIsNull() { IDataProviderProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Create(CreateMySqlDataReader(), null, _fixture.Create <string>(), _fixture.Create <string>(), _fixture.Create <string>())); TestHelper.AssertArgumentNullExceptionIsValid(result, "dataProvider"); }