Пример #1
0
        public void GetById_ShouldReturnNull_WhenWrongId()
        {
            // Arrange
            var context = GetContext(TestData.constructionTypes);
            var repo    = new SqlConstructionTypeRepo(context);

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

            // Assert
            Assert.Null(constructionType);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
Пример #2
0
        public void GetById_ShouldReturnConstructionType()
        {
            // Arrange
            var context = GetContext(TestData.constructionTypes);
            var repo    = new SqlConstructionTypeRepo(context);

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

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

            // Assert
            Assert.Equal(TestData.constructionTypes.SingleOrDefault(v => v.Id == id),
                         constructionType);

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