public void SaveTeammate()
        {
            var body = new CreateTeammateRequest {
                FirstName = Faker.Name.First(), LastName = Faker.Name.Last(), PrimaryPosition = "SF", IsStarter = false
            };
            var subject = new CreateTeammateResponse {
                FirstName = Faker.Name.First(), LastName = Faker.Name.Last(), ID = 5000
            };

            facade.Setup(x => x.CreateTeammate(It.IsNotNull <CreateTeammateRequest>()))
            .Returns(subject)
            .Verifiable();

            // Arrange
            TeamController controller = new TeamController(facade.Object);

            // Act
            var result = controller.CreateTeammate(body);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(CreatedContentActionResult <CreateTeammateResponse>));

            var response = result as CreatedContentActionResult <CreateTeammateResponse>;

            Assert.AreEqual(subject, response._response);
            facade.Verify(x => x.CreateTeammate(It.IsNotNull <CreateTeammateRequest>()), Times.Once);
            facade.VerifyNoOtherCalls();
        }
        /// <summary>
        /// Add a new teammate to the team
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public virtual CreateTeammateResponse CreateTeammate(CreateTeammateRequest request)
        {
            var source   = mapper.Map <CreateTeammateRequest, Teammate>(request);
            var teammate = service.CreateTeammate(source);

            return(mapper.Map <Teammate, CreateTeammateResponse>(teammate));
        }
Esempio n. 3
0
        public virtual IHttpActionResult CreateTeammate([FromBody] CreateTeammateRequest body)
        {
            Guard.NotNull(body, "Message Body");
            var result = searchFacade.CreateTeammate(body);

            string uri = this.Url == null ? "error" : this.Url.Link("GetTeammate", new { id = result.ID });

            return(new CreatedContentActionResult <CreateTeammateResponse>(result, uri));
        }
            public bool Equals(CreateTeammateRequest x, Teammate y)
            {
                if (x == null || y == null)
                {
                    return(false);
                }

                string position = y.PrimaryPosition.HasValue ?
                                  Enum.GetName(y.PrimaryPosition.Value.GetType(), y.PrimaryPosition.Value) : null;

                return(y != null &&
                       x.FirstName == y.FirstName &&
                       x.LastName == y.LastName &&
                       x.BirthDate == y.BirthDate &&
                       x.Height == y.Height &&
                       x.PrimaryPosition == position &&
                       x.IsStarter == y.IsStarter &&
                       x.Interests == y.Interests &&
                       x.Address == y.Address &&
                       x.City == y.City &&
                       x.State == y.State &&
                       x.Zipcode == y.Zipcode);
            }