public void TestThatMapRelationsCallsCloneOnDataProviderOneTime() { IStorageTypeProxy sut = CreateSut(Guid.NewGuid()); Assert.That(sut, Is.Not.Null); IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider(); sut.MapRelations(dataProvider); dataProvider.AssertWasCalled(m => m.Clone(), opt => opt.Repeat.Once()); }
public void TestThatMapRelationsMapsTranslationsIntoProxy() { IStorageTypeProxy sut = CreateSut(Guid.NewGuid()); Assert.That(sut, Is.Not.Null); IEnumerable <TranslationProxy> translationProxyCollection = _fixture.CreateMany <TranslationProxy>().ToList(); IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider(translationProxyCollection); sut.MapRelations(dataProvider); Assert.That(sut.Translation, Is.Null); Assert.That(sut.Translations, Is.Not.Null); Assert.That(sut.Translations, Is.Not.Empty); Assert.That(sut.Translations, Is.EqualTo(translationProxyCollection)); }
public void TestThatMapRelationsCallsGetCollectionOnDataProviderToGetTranslations() { Guid storageTypeIdentifier = Guid.NewGuid(); IStorageTypeProxy sut = CreateSut(storageTypeIdentifier); Assert.That(sut, Is.Not.Null); IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider(); sut.MapRelations(dataProvider); 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", storageTypeIdentifier) .Build(); dataProvider.AssertWasCalled(m => m.GetCollection <TranslationProxy>(Arg <MySqlCommand> .Matches(cmd => commandTester.Run(cmd))), opt => opt.Repeat.Once()); }
public void TestThatMapRelationsThrowsIntranetRepositoryExceptionWhenIdentifierIsNull() { IStorageTypeProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); Assert.That(sut.Identifier, Is.Null); Assert.That(sut.Identifier.HasValue, Is.False); IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.MapRelations(CreateFoodWasteDataProvider())); TestHelper.AssertIntranetRepositoryExceptionIsValid(result, ExceptionMessage.IllegalValue, sut.Identifier, "Identifier"); }
public void TestThatMapRelationsThrowsArgumentNullExceptionIfDataProviderIsNull() { IStorageTypeProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.MapRelations(null)); TestHelper.AssertArgumentNullExceptionIsValid(result, "dataProvider"); }