public void CreateSession_ReturnsSessionId()
        {
            // Arrange
            RestResource resource = new SessionResource();

            RestResponse response = new RestResponse()
            {
                StatusCode = HttpStatusCode.OK,
                Content = "serialisedResponse"
            };

            EsendexSession expectedResult = new EsendexSession()
            {
                Id = Guid.NewGuid()
            };

            mockRestClient
                .Setup(rc => rc.Post(resource))
                .Returns(response);

            mockSerialiser
                .Setup(s => s.Deserialise<EsendexSession>(response.Content))
                .Returns(expectedResult);

            // Act
            Guid actualSessionId = service.CreateSession();

            // Assert
            Assert.AreEqual(expectedResult.Id, actualSessionId);
        }
        /// <summary>
        /// Creates a System.Guid instance that contains the session id.
        /// </summary>
        /// <returns>A System.Guid instance that contains the session id.</returns>
        /// <exception cref="System.Net.WebException"></exception>
        public Guid CreateSession()
        {
            RestResource resource = new SessionResource();

            EsendexSession session = MakeRequest <EsendexSession>(HttpMethod.POST, resource);

            return(session.Id);
        }
예제 #3
0
        /// <summary>
        /// Determines whether the specified System.Object are considered equal.
        /// </summary>
        /// <param name="obj">The System.Object to compare with the current System.Object</param>
        /// <returns>true if the specified System.Object is equal to the current System.Object; otherwise, false.</returns>
        public override bool Equals(object obj)
        {
            EsendexSession other = obj as EsendexSession;

            if (other == null)
            {
                return(false);
            }

            if (Id != other.Id)
            {
                return(false);
            }

            return(true);
        }