示例#1
0
        public void Create_HomeworkIsValid_ShouldCreateNewHomework()
        {
            // arrange - подготавливаем данные
            var fixture = new Fixture();

            var homework = fixture.Build <Homework>()
                           .Without(x => x.MentorId)
                           .Create();

            // act - запускаем тестируемый метод
            var result = _service.Create(homework);

            // assert - проверяем/валидируем результаты теста
            result.Should().BeTrue();
            _homeworksRespositoryMock.Verify(x => x.Add(homework), Times.Once);
        }
示例#2
0
        public async Task Create_HomeworkIsValide_ShouldCreateNewHomework()
        {
            // arrange
            var fixture            = new Fixture();
            var expectedHomeworkId = fixture.Create <int>();
            var homework           = fixture.Build <Homework>().Create();

            _homeworkRepositoryMock.Setup(x => x.Add(homework))
            .ReturnsAsync(expectedHomeworkId);

            // act
            var result = await _service.Create(homework);

            // assert
            result.Should().Be(expectedHomeworkId);
            _homeworkRepositoryMock.Verify(x => x.Add(homework), Times.Once);
        }
示例#3
0
        public async Task Create_HomeworkIsValid_ShouldCreateNewHomework()
        {
            // arrange - подготавливаем данные
            var fixture = new Fixture();

            var expectedHomeworkId = fixture.Create <int>();

            var homework = fixture.Build <Homework>()
                           .Without(x => x.MentorId)
                           .Create();

            _homeworksRespositoryMock.Setup(x => x.Add(homework))
            .ReturnsAsync(expectedHomeworkId);

            // act - запускаем тестируемый метод
            var result = await _service.Create(homework);

            // assert - проверяем/валидируем результаты теста
            result.Should().Be(expectedHomeworkId);
            _homeworksRespositoryMock.Verify(x => x.Add(homework), Times.Once);
        }