public void GetRequiredByCode_WhenExists_Returns(string definitionCode) { var customEntityRepository = GetCustomEntityRepository(); var entityDefinitions = GetBaseEntityDefinitions(); var repo = new EntityDefinitionRepository(entityDefinitions, customEntityRepository); var result = repo.GetByCode(definitionCode); result.EntityDefinitionCode.Should().Be(definitionCode); }
public void GetByCode_WhenNotExists_ReturnsNull() { var customEntityRepository = GetCustomEntityRepository(); var entityDefinitions = GetBaseEntityDefinitions(); var repo = new EntityDefinitionRepository(entityDefinitions, customEntityRepository); var result = repo.GetByCode("UNIQUE"); result.Should().BeNull(); }
public void GetByCode_WhenExists_Returns(string definitionCode) { var customEntityRepository = GetCustomEntityRepository(); var entityDefinitions = GetBaseEntityDefinitions(); var repo = new EntityDefinitionRepository(entityDefinitions, customEntityRepository); var result = repo.GetByCode(definitionCode); Assert.Equal(definitionCode, result.EntityDefinitionCode); }
public void GetAll_WhenNotEmpty_ReturnsAll() { var customEntityRepository = GetCustomEntityRepository(); var entityDefinitions = GetBaseEntityDefinitions(); var total = customEntityRepository.GetAll().Count() + entityDefinitions.Count; var repo = new EntityDefinitionRepository(entityDefinitions, customEntityRepository); var result = repo.GetAll(); result.Should().HaveCount(total); }
public void GetRequiredByCode_WhenNotExists_Throws() { var customEntityRepository = GetCustomEntityRepository(); var entityDefinitions = GetBaseEntityDefinitions(); var repo = new EntityDefinitionRepository(entityDefinitions, customEntityRepository); repo.Invoking(r => r.GetRequiredByCode("UNIQUE")) .Should() .Throw <EntityNotFoundException <IEntityDefinition> >(); }
public void GetAll_WhenEmpty_ReturnsNone() { var mock = new Mock <ICustomEntityDefinitionRepository>(); mock.Setup(r => r.GetAll()).Returns(() => Enumerable.Empty <ICustomEntityDefinition>()); var customEntityRepository = mock.Object; var entityDefinitions = Enumerable.Empty <IEntityDefinition>(); var repo = new EntityDefinitionRepository(entityDefinitions, customEntityRepository); var result = repo.GetAll(); Assert.Empty(result); }