Exemplo n.º 1
0
        public void Add_ShouldAddConstruction()
        {
            // Arrange
            var context = GetContext();
            var repo    = new SqlConstructionRepo(context);

            int specificationId  = _rnd.Next(1, _specifications.Count());
            int typeId           = _rnd.Next(1, _constructionTypes.Count());
            int subtypeId        = _rnd.Next(1, _constructionSubtypes.Count());
            int weldingControlId = _rnd.Next(1, _weldingControl.Count());
            var construction     = new Construction
            {
                Specification = _specifications.SingleOrDefault(v => v.Id == specificationId),
                Name          = "NewCreate",
                Type          = _constructionTypes.SingleOrDefault(v => v.Id == typeId),
                Subtype       = _constructionSubtypes.SingleOrDefault(v => v.Id == subtypeId),
                Valuation     = "1700",
                NumOfStandardConstructions = 0,
                HasEdgeBlunting            = false,
                HasDynamicLoad             = false,
                HasFlangedConnections      = false,
                WeldingControl             = _weldingControl.SingleOrDefault(v => v.Id == weldingControlId),
                PaintworkCoeff             = 1,
            };

            // Act
            repo.Add(construction);

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

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