public async Task UpdateAsyncWhenIdIsCorrectReturnsTutorInstance()
        {
            // 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.Update(Tutor));
            var service = new TutorService(mockTutorRepository.Object, mockUnitOfWork.Object, mockExpertTopicRepository.Object);

            // Act
            TutorResponse result = await service.UpdateAsync(TutorId, Tutor);

            var resource = result.Resource;

            // Assert
            resource.Should().Equals(Tutor);
        }
예제 #2
0
        public async Task PutAsyncWhenTutorsReturnsTutor()
        {
            // Arrange
            var mockTutorRepository   = GetDefaultITutorRepositoryInstance();
            var mockIUnitOfWork       = GetDefaultIUnitOfWorkInstance();
            var mockFacultyRepository = GetDefaultIFacultyRepositoryInstance();
            var mockAccountRepository = GetDefaultIAccountRepositoryInstance();

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

            tutor.Id        = tutorId;
            tutor.FirstName = "Jose";

            Tutor tutorExpected = new Tutor();

            tutorExpected.FirstName = "Lucas";

            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.UpdateAsync(tutorId, tutorExpected);

            // Assert
            Assert.AreEqual(tutorExpected.FirstName, result.Resource.FirstName);
        }
        public async Task UpdateAsyncWhenInvalidIdReturnsTutorNotFoundResponse()
        {
            // 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>(null));
            mockTutorRepository.Setup(r => r.Update(Tutor));
            var service = new TutorService(mockTutorRepository.Object, mockUnitOfWork.Object, mockExpertTopicRepository.Object);

            // Act
            TutorResponse result = await service.UpdateAsync(TutorId, Tutor);

            var message = result.Message;

            // Assert
            message.Should().Be("Tutor not found");
        }