Пример #1
0
        public void Update_ShouldUpdateMark()
        {
            // Arrange
            var marks = new List <Mark> {
            };

            foreach (var m in TestData.marks)
            {
                marks.Add(new Mark
                {
                    Id                   = m.Id,
                    Subnode              = m.Subnode,
                    Code                 = m.Code,
                    Name                 = m.Name,
                    Department           = m.Department,
                    ChiefSpecialist      = m.ChiefSpecialist,
                    GroupLeader          = m.GroupLeader,
                    MainBuilder          = m.MainBuilder,
                    EditedDate           = m.EditedDate,
                    Signed1Id            = m.Signed1Id,
                    Signed2Id            = m.Signed2Id,
                    IssuedDate           = m.IssuedDate,
                    NumOfVolumes         = m.NumOfVolumes,
                    SafetyCoeff          = m.SafetyCoeff,
                    OperatingTemp        = m.OperatingTemp,
                    OperatingZone        = m.OperatingZone,
                    GasGroup             = m.GasGroup,
                    Aggressiveness       = m.Aggressiveness,
                    Material             = m.Material,
                    PaintworkType        = m.PaintworkType,
                    Note                 = m.Note,
                    FireHazardCategoryId = m.FireHazardCategoryId,
                    HighTensileBolts     = m.HighTensileBolts,
                    P_transport          = m.P_transport,
                    P_site               = m.P_site,
                    Xcnd                 = m.Xcnd,
                    Text_3d_estimate     = m.Text_3d_estimate,
                    AddVolumes           = m.AddVolumes,
                    VmpWeight            = m.VmpWeight,
                    Impl_3d_estimate     = m.Impl_3d_estimate,
                });
            }
            var context = GetContext(marks);
            var repo    = new SqlMarkRepo(context);

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

            mark.Name = "NewUpdate";

            // Act
            repo.Update(mark);

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

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

            var mark = repo.GetById(999);

            // Assert
            Assert.Null(mark);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
Пример #3
0
        public void Update_ShouldUpdateMark()
        {
            // Arrange
            var marks = new List <Mark> {
            };

            foreach (var m in TestData.marks)
            {
                marks.Add(new Mark
                {
                    Id                   = m.Id,
                    Subnode              = m.Subnode,
                    Code                 = m.Code,
                    Name                 = m.Name,
                    Department           = m.Department,
                    ChiefSpecialist      = m.ChiefSpecialist,
                    GroupLeader          = m.GroupLeader,
                    NormContr            = m.NormContr,
                    EditedDate           = m.EditedDate,
                    Signed1Id            = m.Signed1Id,
                    Signed2Id            = m.Signed2Id,
                    IssueDate            = m.IssueDate,
                    NumOfVolumes         = m.NumOfVolumes,
                    PaintworkType        = m.PaintworkType,
                    Note                 = m.Note,
                    FireHazardCategoryId = m.FireHazardCategoryId,
                    PTransport           = m.PTransport,
                    PSite                = m.PSite,
                });
            }
            var context = GetContext(marks);
            var repo    = new SqlMarkRepo(context);

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

            mark.Name = "NewUpdate";

            // Act
            repo.Update(mark);

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

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

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

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

            // Assert
            Assert.Equal(TestData.marks.SingleOrDefault(v => v.Id == id),
                         mark);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
Пример #5
0
        public void Add_ShouldAddMark()
        {
            // Arrange
            var context = GetContext(TestData.marks);
            var repo    = new SqlMarkRepo(context);

            int subnodeId         = _rnd.Next(1, TestData.subnodes.Count());
            int departmentId      = _rnd.Next(1, TestData.departments.Count());
            int chiefSpecialistId = _rnd.Next(1, TestData.employees.Count());
            int groupLeaderId     = _rnd.Next(1, TestData.employees.Count());
            int mainBuilderId     = _rnd.Next(1, TestData.employees.Count());
            var mark = new Mark
            {
                Subnode = TestData.subnodes.SingleOrDefault(
                    v => v.Id == subnodeId
                    ),
                Code       = "NewCreate",
                Name       = "NewCreate",
                Department = TestData.departments.SingleOrDefault(
                    v => v.Id == departmentId
                    ),
                ChiefSpecialist = TestData.employees.SingleOrDefault(
                    v => v.Id == chiefSpecialistId
                    ),
                GroupLeader = TestData.employees.SingleOrDefault(
                    v => v.Id == groupLeaderId
                    ),
                MainBuilder = TestData.employees.SingleOrDefault(
                    v => v.Id == mainBuilderId
                    ),
            };

            // Act
            repo.Add(mark);

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

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