public void GetNonExistingSingleEntity() { // Arrange // Create a repository with a mock dbset, so any queries will be done against the list rather than DB SimpleEntityRepository entityRepository = CreateSimpleEntityRepositoryWithMockDbSet( new List <SimpleEntity> { new SimpleEntity { Id = 10 } } ); // Act SimpleEntity entity = entityRepository.GetSingle(se => se.Id == 9999); // Assert Assert.IsNull(entity); }
/// <summary> /// Tests that when we query for an existing entity, it is returned correctly /// </summary> //[Test] public void GetExistingSingleEntity() { // Arrange const int expectedId = 10; // Create a repository with a mock dbset, so any queries will be done against the list rather than DB SimpleEntityRepository entityRepository = CreateSimpleEntityRepositoryWithMockDbSet( new List <SimpleEntity> { new SimpleEntity { Id = expectedId } } ); // Act SimpleEntity entity = entityRepository.GetSingle(se => se.Id == expectedId); // Assert Assert.IsNotNull(entity); Assert.AreEqual(expectedId, entity.Id); }