public void ShouldReturnProjectVmForEdit() { var project = new Project() { Id = 1, ProjectStatusId = 1, Number = "12345", Name = "test", DestinationId = 1, CreatedDateTime = DateTime.Now }; var destList = new List <Destination>() { new Destination() { Id = 1, CountryId = 1, Country = new Country() { Id = 1, Name = "country", SubsistanceAllowenceId = 1 }, Name = "x", CreatedDateTime = DateTime.Now }, new Destination() { Id = 2, CountryId = 1, Country = new Country() { Id = 1, Name = "country", SubsistanceAllowenceId = 1 }, Name = "y", CreatedDateTime = DateTime.Now }, new Destination() { Id = 3, CountryId = 1, Country = new Country() { Id = 1, Name = "country", SubsistanceAllowenceId = 1 }, Name = "z", CreatedDateTime = DateTime.Now } }; var projStatusList = new List <ProjectStatus>() { new ProjectStatus() { Id = 1, Name = "Opened" }, new ProjectStatus() { Id = 2, Name = "Closed" } }; var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); var destRepo = new Mock <IDestinationRepository>(); destRepo.Setup(d => d.GetDestinations()).Returns(destList.AsQueryable()); destRepo.Setup(d => d.GetProjectStatuses()).Returns(projStatusList.AsQueryable()); destRepo.Setup(d => d.GetProjectById(1)).Returns(project); var destServ = new DestinationService(destRepo.Object, mapper); var projVmForEdit = destServ.GetProjectForEdit(1); projVmForEdit.Should().BeOfType(typeof(NewProjectVm)); projVmForEdit.Should().NotBeNull(); projVmForEdit.Destinations.Should().AllBeOfType(typeof(DestinationTypeVm)); projVmForEdit.Destinations.Should().HaveCount(3); projVmForEdit.Destinations.Should().OnlyHaveUniqueItems(d => d.Id); projVmForEdit.Statuses.Should().AllBeOfType(typeof(ProjectStatusVm)); projVmForEdit.Statuses.Should().HaveCount(2); projVmForEdit.Statuses.Should().OnlyHaveUniqueItems(s => s.Id); }