public void Can_Perform_Exists_On_LanguageRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new LanguageRepository(unitOfWork); // Act var exists = repository.Exists(3); var doesntExist = repository.Exists(10); // Assert Assert.That(exists, Is.True); Assert.That(doesntExist, Is.False); }
public void ChangeLanguage(string languageCode) { if (LanguageRepository.Exists(l => l.Code == languageCode)) { LocalizationRepository = new JsonLocalizationRepository(languageCode, LocalizableCodeRepository); LanguageChanged?.Invoke(this, languageCode); } }
public void Can_Perform_Exists_On_LanguageRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { LanguageRepository repository = CreateRepository(provider); // Act bool exists = repository.Exists(3); bool doesntExist = repository.Exists(10); // Assert Assert.That(exists, Is.True); Assert.That(doesntExist, Is.False); } }
public void Can_Perform_Delete_On_LanguageRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new LanguageRepository(unitOfWork); // Act var language = repository.Get(3); repository.Delete(language); unitOfWork.Commit(); var exists = repository.Exists(3); // Assert Assert.That(exists, Is.False); }
public void Can_Perform_Delete_On_LanguageRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { LanguageRepository repository = CreateRepository(provider); // Act ILanguage language = repository.Get(3); repository.Delete(language); bool exists = repository.Exists(3); // Assert Assert.That(exists, Is.False); } }
public void Can_Perform_Delete_On_LanguageRepository_With_Language_Used_As_Fallback() { // Arrange IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { // Add language to delete as a fall-back language to another one LanguageRepository repository = CreateRepository(provider); ILanguage languageToFallbackFrom = repository.Get(5); languageToFallbackFrom.FallbackLanguageId = 2; // fall back to #2 (something we can delete) repository.Save(languageToFallbackFrom); // delete #2 ILanguage languageToDelete = repository.Get(2); repository.Delete(languageToDelete); bool exists = repository.Exists(2); // has been deleted Assert.That(exists, Is.False); } }
public async Task Exists_ShouldReturnFalse_WhenLanguageDoesNotExist() { // Arrange const int languageId = 51; IEnumerable <Language> languages = new[] { new Language { LanguageId = 1, Code = "EN", Name = "Language.English" }, new Language { LanguageId = 2, Code = "DE", Name = "Language.German" }, new Language { LanguageId = 3, Code = "FR", Name = "Language.French" }, }; Mock <DbSet <Language> > languageDbSetMock = languages .AsQueryable() .BuildMockDbSet(); Mock <IChatContext> contextMock = new Mock <IChatContext>(); contextMock .Setup(m => m.Languages) .Returns(languageDbSetMock.Object); ILanguageRepository languageRepository = new LanguageRepository(contextMock.Object); // Act bool exists = await languageRepository.Exists(languageId); // Assert Assert.False(exists); }
public void Can_Perform_Exists_On_LanguageRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new LanguageRepository(unitOfWork); // Act var exists = repository.Exists(3); var doesntExist = repository.Exists(10); // Assert Assert.That(exists, Is.True); Assert.That(doesntExist, Is.False); }
public void Can_Perform_Delete_On_LanguageRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new LanguageRepository(unitOfWork); // Act var language = repository.Get(3); repository.Delete(language); unitOfWork.Commit(); var exists = repository.Exists(3); // Assert Assert.That(exists, Is.False); }