Exemple #1
0
        public void GetById_ShouldReturnNull_WhenWrongId()
        {
            // Arrange
            var context = GetContext(TestData.projects);
            var repo    = new SqlProjectRepo(context);

            // Act
            var project = repo.GetById(999);

            // Assert
            Assert.Null(project);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
Exemple #2
0
        public void GetById_ShouldReturnProject()
        {
            // Arrange
            var context = GetContext(TestData.projects);
            var repo    = new SqlProjectRepo(context);

            int id = _rnd.Next(1, TestData.projects.Count());

            // Act
            var project = repo.GetById(id);

            // Assert
            Assert.Equal(TestData.projects.SingleOrDefault(v => v.Id == id), project);

            context.Database.EnsureDeleted();
            context.Dispose();
        }