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

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

            // Assert
            Assert.Null(docType);

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

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

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

            // Assert
            Assert.Equal(TestData.docTypes.SingleOrDefault(v => v.Id == id),
                         docType);

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