示例#1
0
        // In this simple test we check if the number
        // of the segments in the database is incremented
        // when we add try to add a line

        public void TestAddLine()
        {
            //Arrange
            var segment = new SegmentViewModel
            {
                Line1          = "Dummy",
                Line2          = "Dummy",
                Original1      = "Dummy",
                Original2      = "Dummy",
                TranslationID  = 1,
                TimestampEnd   = "00:06:30,000",
                TimestampStart = "00:06:10,000",
            };
            var mockUnitOfWork = new MockUnitOfWork();

            for (int i = 0; i < 3; i++)
            {
                var reposegment = new TranslationSegment();
                mockUnitOfWork.TranslationSegmentRepository.Insert(reposegment);
            }
            ;


            var controller  = new TranslationController(mockUnitOfWork);
            int countbefore = mockUnitOfWork.TranslationSegmentRepository.Get().ToList().Count;
            // Act
            var result = controller.AddLine(segment);

            // Assert
            Assert.IsTrue(mockUnitOfWork.TranslationSegmentRepository.Get().ToList().Count == countbefore + 1);
        }