コード例 #1
0
        public void ShouldReturnDestinationDetails()
        {
            var destination = new Destination()
            {
                Id              = 1,
                CountryId       = 1,
                Name            = "test",
                CreatedDateTime = DateTime.Now
            };

            var projects = new List <Project>()
            {
                new Project()
                {
                    Id            = 1, Name = "project1", Number = "111", Destination = destination, ProjectStatusId = 1,
                    ProjectStatus = new ProjectStatus()
                    {
                        Id = 1, Name = "open"
                    }
                }
            };

            destination.Projects = projects;
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper   = config.CreateMapper();
            var destRepo = new Mock <IDestinationRepository>();

            destRepo.Setup(d => d.GetDestinationById(1)).Returns(destination);
            var destServ = new DestinationService(destRepo.Object, mapper);

            var destDetailsVm = destServ.GetDestinationDetail(1);

            destDetailsVm.Should().BeOfType(typeof(DestinationDetailVm));
            destDetailsVm.Should().NotBeNull();
            destDetailsVm.Projects.Should().BeOfType(typeof(ListProjectForList));
            destDetailsVm.Projects.Should().NotBeNull();
            destDetailsVm.Projects.Projects.Should().AllBeOfType(typeof(ProjectForListVm));
            destDetailsVm.Projects.Projects.Should().HaveCount(1);
            destDetailsVm.Projects.Count.Should().Be(1);
        }