Example #1
0
        public void Add_WhenLeftSizeIs8001_ShouldThrowException()
        {
            //arrange
            _context.Database.EnsureCreated();
            var differenceLeftRepository = new DifferenceLeftRepository(_context);
            int id = 1;

            //Act
            var difference = new DifferenceLeft(id, new string('a', 8001));

            differenceLeftRepository.Add(difference);

            //Assert
            Exception ex = Assert.Throws <DbUpdateException>(() => differenceLeftRepository.Add(difference));
        }
Example #2
0
        public void Add_WhenPropertiesFilled_ShouldSave()
        {
            //arrange
            _context.Database.EnsureCreated();
            var differenceLeftRepository = new DifferenceLeftRepository(_context);
            int id = 1;

            //Act
            var differenceSaved = new DifferenceLeft(id, "a");

            differenceLeftRepository.Add(differenceSaved);
        }
Example #3
0
        public void Add_WhenLeftSizeIs8000_ShouldSave()
        {
            //arrange
            _context.Database.EnsureCreated();
            var differenceLeftRepository = new DifferenceLeftRepository(_context);
            int id = 1;

            //Act
            var differenceSaved = new DifferenceLeft(id, new string('a', 8000));

            differenceLeftRepository.Add(differenceSaved);
        }
Example #4
0
        public void Add_WhenLeftIsNull_ShouldThrowDbUpdateException()
        {
            //Arrange
            _context.Database.EnsureCreated();
            var differenceLeftRepository = new DifferenceLeftRepository(_context);

            //Act
            var difference = new DifferenceLeft(1, null);

            //Assert
            Exception ex = Assert.Throws <DbUpdateException>(() => differenceLeftRepository.Add(difference));
        }
Example #5
0
        public async void GetById_WhenProperlySaved_ShouldReturnEqualValues()
        {
            //arrange
            _context.Database.EnsureCreated();
            var differenceLeftRepository = new DifferenceLeftRepository(_context);
            int id = 1;

            //Act
            var differenceSaved = new DifferenceLeft(id, "a");

            differenceLeftRepository.Add(differenceSaved);

            var differenceReturned = await differenceLeftRepository.GetById(id);


            //Assert
            Assert.Equal <Difference>(differenceSaved, differenceReturned);
        }