コード例 #1
0
        public void SearchTeam()
        {
            var subject = new Teammate
            {
                FirstName = Faker.Name.First(),
                LastName  = Faker.Name.Last(),
                Address   = Faker.Address.StreetAddress(),
                City      = Faker.Address.City(),
                BirthDate = DateTime.Parse($"{Faker.RandomNumber.Next(1, 12)}/{Faker.RandomNumber.Next(1, 28)}/{Faker.RandomNumber.Next(1960, 2000)}"),
                ID        = Faker.RandomNumber.Next(1, 1000),
                Interests = Faker.Lorem.Sentence(3),
                IsStarter = Convert.ToBoolean(Faker.RandomNumber.Next(0, 1)),
                State     = Faker.Address.UsStateAbbr(),
                Zipcode   = Faker.Address.ZipCode(),
            };

            var mapped = mapper.Map <Teammate, GetTeammateResponse>(subject);

            service.Setup(x => x.SearchTeam(It.IsAny <string>()))
            .Returns(new List <Teammate>()
            {
                subject
            })
            .Verifiable();

            var result = facade.SearchTeam(subject.FirstName).FirstOrDefault();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.FirstName == mapped.FirstName &&
                          result.LastName == mapped.LastName &&
                          result.ID == mapped.ID &&
                          result.Interests == mapped.Interests &&
                          result.IsStarter == mapped.IsStarter &&
                          result.BirthDate.Equals(mapped.BirthDate) &&
                          result.Address == mapped.Address &&
                          result.Age == mapped.Age);
            service.Verify(x => x.SearchTeam(It.IsAny <string>()), Times.Once);
        }
コード例 #2
0
        public IHttpActionResult SearchTeam([FromUri] string term)
        {
            var target = searchFacade.SearchTeam(term);

            return(Ok(target));
        }