Exemple #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);
        }
Exemple #2
0
 private bool HaveEqualState(Qubiz.QuizEngine.Services.SectionService.Contract.Section expected, Section actual)
 {
     return(expected.ID == actual.ID &&
            expected.Name == actual.Name);
 }