public void GetWorkExperienceByIdProfile_InvalidProfileId_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); WorkExperienceService service = new WorkExperienceService(uow.Object); uow.Setup(a => a.ProgrammerProfiles.Get(It.IsAny <string>())).Returns((ProgrammerProfile)null); service.GetWorkExperienceByProfileId(It.IsAny <string>()); }
public void GetWorkExperienceByIdProfile_GetWorkExperienceWithCorrectProfileId_ShouldBeRecieved() { Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); IUnitOfWork uow = mock.Object; WorkExperienceService service = new WorkExperienceService(uow); IEnumerable <WorkExperience> workExperiences = new List <WorkExperience> { new WorkExperience() { Id = 1, ProgrammerId = "1" }, new WorkExperience() { Id = 2, ProgrammerId = "1" }, new WorkExperience() { Id = 3, ProgrammerId = "1" } }; var expected = new List <WorkExperienceDTO> { new WorkExperienceDTO() { Id = 1, ProgrammerId = "1" }, new WorkExperienceDTO() { Id = 2, ProgrammerId = "1" }, new WorkExperienceDTO() { Id = 3, ProgrammerId = "1" } }; mock.Setup(a => a.ProgrammerProfiles.Get(It.IsAny <string>())).Returns(new ProgrammerProfile()); mock.Setup(a => a.WorkExperiences.GetAll()).Returns(workExperiences); var actual = service.GetWorkExperienceByProfileId("1"); CollectionAssert.AreEquivalent(actual.Select(x => x.Id).ToList(), expected.Select(x => x.Id).ToList()); CollectionAssert.AreEquivalent(actual.Select(x => x.ProgrammerId).ToList(), expected.Select(x => x.ProgrammerId).ToList()); }