Пример #1
0
        public void Add_ShouldAddstandardConstruction()
        {
            // Arrange
            var context = GetContext();
            var repo    = new SqlStandardConstructionRepo(context);

            int specificationId      = _rnd.Next(1, _specifications.Count());
            var standardConstruction = new StandardConstruction
            {
                Specification = _specifications.SingleOrDefault(v => v.Id == specificationId),
                Name          = "NewCreate",
                Num           = 1,
                Sheet         = "NewCreate",
                Weight        = 1.0f,
            };

            // Act
            repo.Add(standardConstruction);

            // Assert
            Assert.NotNull(repo.GetById(standardConstruction.Id));

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

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

            // Assert
            Assert.Null(standardConstruction);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
Пример #3
0
        public void GetById_ShouldReturnstandardConstruction()
        {
            // Arrange
            var context = GetContext();
            var repo    = new SqlStandardConstructionRepo(context);

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

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

            // Assert
            Assert.Equal(_standardConstructions.SingleOrDefault(v => v.Id == id), standardConstruction);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
Пример #4
0
        public void Delete_ShouldDeletestandardConstruction()
        {
            // Arrange
            var context = GetContext();
            var repo    = new SqlStandardConstructionRepo(context);

            int id = _rnd.Next(1, _standardConstructions.Count());
            var standardConstruction = _standardConstructions.FirstOrDefault(v => v.Id == id);

            // Act
            repo.Delete(standardConstruction);

            // Assert
            Assert.Null(repo.GetById(id));

            context.Database.EnsureDeleted();
            context.Dispose();
        }
Пример #5
0
        public void Update_ShouldUpdatestandardConstruction()
        {
            // Arrange
            var context = GetContext(true);
            var repo    = new SqlStandardConstructionRepo(context);

            int id = _rnd.Next(1, _updateStandardConstructions.Count());
            var standardConstruction = _updateStandardConstructions.FirstOrDefault(v => v.Id == id);

            standardConstruction.Name = "NewUpdate";

            // Act
            repo.Update(standardConstruction);

            // Assert
            Assert.Equal(standardConstruction.Name, repo.GetById(id).Name);

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