示例#1
0
        public void ICanSerializeAndDeserializeAGetOperationStatusWithNoErrorDetails()
        {
            var responseObject = new UserChangeOperationStatusResponse()
            {
                OperationType    = UserChangeOperationType.Enable,
                UserType         = UserType.Http,
                RequestIssueDate = DateTime.UtcNow,
                State            = UserChangeOperationState.Completed,
                Error            = null
            };

            var passthroughOpStatus = new PassthroughResponse()
            {
                Data  = responseObject,
                Error = null
            };

            // serialize the non error response
            var serializedPassthroughResponse = new ClusterProvisioningServerPayloadConverter();
            var serializedOpResponse          = serializedPassthroughResponse.SerailizeChangeRequestResponse(passthroughOpStatus);

            // now deseialize it
            var deserialized = new PayloadConverter().DeserializeConnectivityStatus(serializedOpResponse);

            Assert.IsNotNull(deserialized, "Nothing was returned from the deserializer.");
            Assert.IsNotNull(deserialized.Data, "No data object was present after deserialization.");
            Assert.AreEqual(responseObject.OperationType.ToString(), deserialized.Data.OperationType.ToString(), "The OperationType did not match after deserialization.");
            Assert.AreEqual(responseObject.RequestIssueDate, deserialized.Data.RequestIssueDate, "The IssueDate did not match after deserialization.");
            Assert.AreEqual(responseObject.State.ToString(), deserialized.Data.State.ToString(), "The State did not match after deserialization.");
            Assert.AreEqual(responseObject.UserType.ToString(), deserialized.Data.UserType.ToString(), "The user type not match after deserialization.");
        }
示例#2
0
        public void ICanSerializeAndDeserializeAGetOperationStatusWithErrorDetails()
        {
            var          errorStatusCode     = HttpStatusCode.NotAcceptable;
            var          errorIdDetails      = "Error123";
            var          errorMessageDetails = "This is an error!";
            ErrorDetails errorDetails        = new ErrorDetails()
            {
                StatusCode   = errorStatusCode,
                ErrorId      = errorIdDetails,
                ErrorMessage = errorMessageDetails
            };

            var userChangeResponse = new UserChangeOperationStatusResponse()
            {
                OperationType    = UserChangeOperationType.Enable,
                UserType         = UserType.Http,
                RequestIssueDate = DateTime.UtcNow,
                State            = UserChangeOperationState.Completed,
                Error            = errorDetails
            };

            var responseObject = new PassthroughResponse()
            {
                Data  = userChangeResponse,
                Error = errorDetails
            };

            // SERIALIZE THE RESPONSE
            var serializedPassthroughResponse = new ClusterProvisioningServerPayloadConverter();
            var serializedOpResponse          = serializedPassthroughResponse.SerailizeChangeRequestResponse(responseObject);

            // now deseialize it
            var deserialized = new PayloadConverter().DeserializeConnectivityStatus(serializedOpResponse);

            Assert.IsNotNull(deserialized, "Nothing was returned from the deserializer.");
            Assert.IsNotNull(deserialized.ErrorDetails, "No error object was present after deserialization.");
            Assert.AreEqual(responseObject.Error.ErrorId, deserialized.ErrorDetails.ErrorId, "The Error Id did not match after deserialization.");
            Assert.AreEqual(responseObject.Error.ErrorMessage, deserialized.ErrorDetails.ErrorMessage, "The error message did not match after deserialization.");
            Assert.AreEqual(responseObject.Error.StatusCode, deserialized.ErrorDetails.StatusCode, "The status code did not match after deserialization.");
            Assert.IsNotNull(deserialized.Data, "No data object was present after deserialization.");
            Assert.AreEqual(userChangeResponse.OperationType.ToString(), deserialized.Data.OperationType.ToString(), "The OperationType did not match after deserialization.");
            Assert.AreEqual(userChangeResponse.RequestIssueDate, deserialized.Data.RequestIssueDate, "The IssueDate did not match after deserialization.");
            Assert.AreEqual(userChangeResponse.State.ToString(), deserialized.Data.State.ToString(), "The State did not match after deserialization.");
            Assert.AreEqual(userChangeResponse.UserType.ToString(), deserialized.Data.UserType.ToString(), "The user type not match after deserialization.");

            Assert.IsNotNull(deserialized.Data.ErrorDetails, "No error object was present after deserialization.");
            Assert.AreEqual(userChangeResponse.Error.ErrorId, deserialized.Data.ErrorDetails.ErrorId, "The (inner) Error Id did not match after deserialization.");
            Assert.AreEqual(userChangeResponse.Error.ErrorMessage, deserialized.Data.ErrorDetails.ErrorMessage, "The (inner) error message did not match after deserialization.");
            Assert.AreEqual(userChangeResponse.Error.StatusCode, deserialized.Data.ErrorDetails.StatusCode, "The (inner) status code did not match after deserialization.");
        }
 public PendingOp(UserChangeOperationStatusResponse response)
 {
     this.Response = response;
     this.Id = Guid.NewGuid();
 }
 public PendingOp(UserChangeOperationStatusResponse response)
 {
     this.Response = response;
     this.Id       = Guid.NewGuid();
 }