public async Task DeleteAsyncWhenIdIsCorrectReturnsTutorInstance()
        {
            // Arrange
            var mockUnitOfWork            = GetDefaultUnitOfWorkRepositoryInstance();
            var mockTutorRepository       = GetDefaultTutorRepositoryInstance();
            var mockExpertTopicRepository = new Mock <IExpertTopicRepository>();
            var TutorId = 1;
            var Tutor   = new Tutor()
            {
                Id           = 1,
                Name         = "string",
                LastName     = "string",
                Description  = "String",
                Logo         = "string",
                Email        = "string",
                Password     = "******",
                PricePerHour = 0
            };

            mockTutorRepository.Setup(r => r.FindById(TutorId)).Returns(Task.FromResult(Tutor));
            mockTutorRepository.Setup(r => r.Remove(Tutor));
            var service = new TutorService(mockTutorRepository.Object, mockUnitOfWork.Object, mockExpertTopicRepository.Object);

            // Act
            TutorResponse result = await service.DeleteAsync(TutorId);

            var instance = result.Resource;

            // Assert
            instance.Should().Be(Tutor);
        }
Exemple #2
0
        public async Task DeleteAsyncWhenTutorReturnsTutor()
        {
            // Arrange
            var mockTutorRepository   = GetDefaultITutorRepositoryInstance();
            var mockIUnitOfWork       = GetDefaultIUnitOfWorkInstance();
            var mockFacultyRepository = GetDefaultIFacultyRepositoryInstance();
            var mockAccountRepository = GetDefaultIAccountRepositoryInstance();

            Tutor tutor   = new Tutor();
            int   tutorId = 102;

            tutor.Id = tutorId;

            mockTutorRepository.Setup(r => r.FindById(tutorId))
            .Returns(Task.FromResult <Tutor>(tutor));

            var service = new TutorService(mockTutorRepository.Object, mockAccountRepository.Object, mockFacultyRepository.Object, mockIUnitOfWork.Object);

            // Act
            TutorResponse result = await service.DeleteAsync(tutorId);

            // Assert
            Assert.AreEqual(tutor, result.Resource);
        }