public void WhenRequestHeaderWithOfflineAuthSessionIsSent_ThenAuthSessionExist()
        {
            Guid offlinePersonGuid = Guid.NewGuid();

            RequestHeader requestHeader = CreateRequestHeader();

            requestHeader.AppId       = null;
            requestHeader.AuthSession = new AuthSession
            {
                AuthToken = "someToken",
                Person    = new OfflinePersonInfo {
                    OfflinePersonId = offlinePersonGuid
                }
            };

            RequestHeaderSerializer requestInfoSerializer = new RequestHeaderSerializer();
            string requestHeaderXml = requestInfoSerializer.Serialize(requestHeader);

            var navigator = requestHeaderXml.AsXPathNavigator();

            XPathNavigator authSessionNavigator = navigator.SelectSingleNode("child::auth-session");

            string authToken       = authSessionNavigator.SelectSingleNode("child::auth-token").Value;
            string offlinePersonId = authSessionNavigator
                                     .SelectSingleNode("child::offline-person-info")
                                     .SelectSingleNode("child::offline-person-id")
                                     .Value;

            Assert.AreEqual("someToken", authToken);
            Assert.AreEqual(offlinePersonGuid.ToString(), offlinePersonId);
        }
        public void WhenRequestHeaderIsSerialized()
        {
            RequestHeader requestHeader = CreateRequestHeader();

            RequestHeaderSerializer requestInfoSerializer = new RequestHeaderSerializer();
            string requestHeaderXml = requestInfoSerializer.Serialize(requestHeader);

            var navigator = requestHeaderXml.AsXPathNavigator();

            string rootName = navigator.Name;

            string methodName     = navigator.SelectSingleNode("child::method").Value;
            string methodVersion  = navigator.SelectSingleNode("child::method-version").Value;
            string targetPersonId = navigator.SelectSingleNode("child::target-person-id").Value;
            string recordId       = navigator.SelectSingleNode("child::record-id").Value;
            string appId          = navigator.SelectSingleNode("child::app-id").Value;
            string cultureCode    = navigator.SelectSingleNode("child::culture-code").Value;
            string msgTime        = navigator.SelectSingleNode("child::msg-time").Value;
            string msgTtl         = navigator.SelectSingleNode("child::msg-ttl").Value;
            string version        = navigator.SelectSingleNode("child::version").Value;
            string infoHash       = navigator.SelectSingleNode("child::info-hash").Value;

            Assert.AreEqual("header", rootName);
            Assert.AreEqual("GetServiceDefinition", methodName);
            Assert.AreEqual("1", methodVersion);
            Assert.AreEqual("someTargetPersonId", targetPersonId);
            Assert.AreEqual("someRecordId", recordId);
            Assert.AreEqual("someAppId", appId);
            Assert.AreEqual("en-US", cultureCode);
            Assert.IsNotNull(msgTime);
            Assert.AreEqual("60", msgTtl);
            Assert.AreEqual("someVersion", version);
            Assert.IsNotNull(infoHash);
        }
        public void WhenRequestHeaderWithUserAuthSessionIsSent_ThenAuthSessionExist()
        {
            RequestHeader requestHeader = CreateRequestHeader();

            requestHeader.AppId       = null;
            requestHeader.AuthSession = new AuthSession
            {
                AuthToken     = "someToken",
                UserAuthToken = "someUserAuthToken"
            };

            RequestHeaderSerializer requestInfoSerializer = new RequestHeaderSerializer();
            string requestHeaderXml = requestInfoSerializer.Serialize(requestHeader);

            var navigator = requestHeaderXml.AsXPathNavigator();

            XPathNavigator authSessionNavigator = navigator.SelectSingleNode("child::auth-session");

            string authToken     = authSessionNavigator.SelectSingleNode("child::auth-token").Value;
            string userAuthToken = authSessionNavigator.SelectSingleNode("child::user-auth-token").Value;

            Assert.AreEqual("someToken", authToken);
            Assert.AreEqual("someUserAuthToken", userAuthToken);
        }