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

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

            // Assert
            Assert.Null(user);

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

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

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

            // Assert
            Assert.Equal(TestData.users.SingleOrDefault(v => v.Id == id), user);

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