コード例 #1
0
        public void GetById_ShouldReturnNull_WhenWrongId()
        {
            // Arrange
            var context = GetContext(TestData.boltLengths);
            var repo    = new SqlBoltLengthRepo(context);

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

            // Assert
            Assert.Null(boltLength);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
コード例 #2
0
        public void GetById_ShouldReturnBoltLength()
        {
            // Arrange
            var context = GetContext(TestData.boltLengths);
            var repo    = new SqlBoltLengthRepo(context);

            var id = _rnd.Next(1, TestData.boltLengths.Count());

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

            // Assert
            Assert.Equal(TestData.boltLengths.SingleOrDefault(
                             v => v.Id == id), boltLength);

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