Пример #1
0
        public async Task AddSectionAsync_WhenAddingUnexistingSection_ThenReturnNoError()
        {
            Qubiz.QuizEngine.Services.SectionService.Contract.Section section = new Qubiz.QuizEngine.Services.SectionService.Contract.Section {
                ID = Guid.NewGuid(), Name = "Test Section"
            };

            unitOfWorkMock.Setup(x => x.SectionRepository).Returns(sectionRepositoryMock.Object);

            sectionRepositoryMock.Setup(x => x.GetByNameAsync(section.Name)).Returns(Task.FromResult((Section)null));

            sectionRepositoryMock.Setup(x => x.Upsert(It.Is <Section>(s => HaveEqualState(section, s))));

            unitOfWorkMock.Setup(x => x.SaveAsync()).Returns(() => Task.CompletedTask);

            ValidationError[] errors = await sectionService.AddSectionAsync(section);

            Assert.AreEqual(0, errors.Length);
        }