public void Get_Returns_User_Information_For_The_Given_User()
        {
            var expectedUserInformation = new UserInformation();

            _autoMocker.Get <IUserRetriever>().Expect(mock => mock.RetrieveUserInformation(_applicationUser))
            .Return(expectedUserInformation);
            UserInformationMessage expectedUserInformationMessage = new UserInformationMessage
            {
                GamingGroups = new List <GamingGroupInfoForUserMessage>
                {
                    new GamingGroupInfoForUserMessage
                    {
                        GamingGroupId = 1
                    },
                    new GamingGroupInfoForUserMessage
                    {
                        GamingGroupId = 2
                    }
                },
                Players = new List <PlayerInfoForUserMessage>
                {
                    new PlayerInfoForUserMessage
                    {
                        PlayerId = 10
                    },
                    new PlayerInfoForUserMessage
                    {
                        PlayerId = 20
                    }
                }
            };

            _autoMocker.Get <ITransformer>().Expect(mock => mock.Transform <UserInformationMessage>(expectedUserInformation))
            .Return(expectedUserInformationMessage);
            _autoMocker.ClassUnderTest.CurrentUser = _applicationUser;

            var actualResponse = _autoMocker.ClassUnderTest.GetUserInformation(_applicationUser.Id);

            Assert.That(actualResponse.Content, Is.TypeOf(typeof(ObjectContent <UserInformationMessage>)));
            var content = actualResponse.Content as ObjectContent <UserInformationMessage>;
            var actualUserInformationMessage = content.Value as UserInformationMessage;

            Assert.That(actualUserInformationMessage, Is.SameAs(expectedUserInformationMessage));

            Assert.That(actualUserInformationMessage.GamingGroups[0].NemeStatsUrl,
                        Is.EqualTo(AbsoluteUrlBuilder.GetGamingGroupDetailsUrl(actualUserInformationMessage.GamingGroups[0]
                                                                               .GamingGroupId)));
            Assert.That(actualUserInformationMessage.GamingGroups[1].NemeStatsUrl,
                        Is.EqualTo(AbsoluteUrlBuilder.GetGamingGroupDetailsUrl(actualUserInformationMessage.GamingGroups[1]
                                                                               .GamingGroupId)));

            Assert.That(actualUserInformationMessage.Players[0].NemeStatsUrl,
                        Is.EqualTo(AbsoluteUrlBuilder.GetPlayerDetailsUrl(actualUserInformationMessage.Players[0]
                                                                          .PlayerId)));
            Assert.That(actualUserInformationMessage.Players[1].NemeStatsUrl,
                        Is.EqualTo(AbsoluteUrlBuilder.GetPlayerDetailsUrl(actualUserInformationMessage.Players[1]
                                                                          .PlayerId)));
        }
예제 #2
0
        public virtual HttpResponseMessage GetUserInformation(string userId)
        {
            var userInformation        = _userRetriever.RetrieveUserInformation(CurrentUser);
            var userInformationMessage = _transformer.Transform <UserInformationMessage>(userInformation);

            userInformationMessage.GamingGroups.ForEach(x => x.NemeStatsUrl = AbsoluteUrlBuilder.GetGamingGroupDetailsUrl(x.GamingGroupId));
            userInformationMessage.Players.ForEach(x => x.NemeStatsUrl      = AbsoluteUrlBuilder.GetPlayerDetailsUrl(x.PlayerId));

            return(Request.CreateResponse(HttpStatusCode.OK, userInformationMessage));
        }